Advertisement

04.14.2004 at 01:15AM PDT, ID: 20953394
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

'my' array variables avoid memory leaks?

Asked by yashgt in Perl Programming Language

Tags: , , , ,

Here is an unexpected behavior in Perl:
#!/usr/bin/perl
$line=readline STDIN;
while ($line ne "") {
    chomp $line;        # remove newline from $line
    @mlsFields = split(/,/,$line);
    $line=readline STDIN;
}
When I run this program on HP-Ux using
cat myfile.txt | a.pl

and monitor the memory usage using top,
I see the memory continuously increasing from
CPU TTY    PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND
 0 pts/0 21224 dilbert  237 20  6552K   720K run      0:04 78.36 17.33 perl
to
CPU TTY    PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND
 1 pts/0 21224 dilbert  227 20 21400K 15492K run      0:49 98.95 90.82 perl
and further.
This implies that the array @mlsfields is repeatedly being allocated without being cleared. I would ideally expect Perl to overwrite the existing array during each iteration of the loop.

Changing the line to :
my @mlsFields = split(/,/,$line);

solved the problem. The memory usage remains stable after making this change.

Can someone explain this?

Also, by making the array my, do you think the array would be overwritten? or would it be deallocated and reallocated for the new iteration?

Thanks
Start Free Trial
 
Loading Advertisement...
 
[+][-]04.14.2004 at 01:28AM PDT, ID: 10821402

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2004 at 01:31AM PDT, ID: 10821417

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2004 at 02:32AM PDT, ID: 10821735

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: memory, perl, avoid, explain, leaks
Sign Up Now!
Solution Provided By: GreenAsJade
Participating Experts: 4
Solution Grade: B
 
 
[+][-]04.14.2004 at 07:18AM PDT, ID: 10823619

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2004 at 03:26PM PDT, ID: 10828432

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2004 at 01:26AM PDT, ID: 10831121

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2004 at 10:31AM PDT, ID: 10835216

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]04.15.2004 at 03:14PM PDT, ID: 10837620

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy