memory problem with test program 
Author Message
 memory problem with test program

We have several perl programs that use a reasonable lot of data in (assoc)
arrays. However, freeing those arrays does not make the memory use smaller. Is
this perl? BSD?

Here is the program and the typical output. The input file has 10000 lines
with info:

=======================snip snip===============================
#! /usr/local/bin/perl

&memory;


close(LIST);
print "Normal array created with ", $#normal+1, " elements\n";
&memory;

open(LIST,"companylist");
while (<LIST>) {
  $assoc{$_} = 1;

Quote:
}

close(LIST);
print "Associative array created with ", $#normal+1, " elements\n";
&memory;


print "Normal array undefined\n";
&memory;

undef %assoc;
print "Associative array undefined\n";
&memory;

reset 'a', 'n';
print "Arrays 'a' and 'n' reset\n";
&memory;


close(LIST);
print "Normal array created with ", $#bormal+1, " elements\n";
&memory;

open(LIST,"companylist");
while (<LIST>) {
  $bssoc{$_} = 1;

Quote:
}

close(LIST);
print "Associative array created with ", $#bormal+1, " elements\n";
&memory;


print "Normal array undefined\n";
&memory;

undef %bssoc;
print "Associative array undefined\n";
&memory;

reset 'b';
print "Arrays 'b' reset\n";
&memory;

sub memory {
  open(PS,"ps -u$$ |") || die "Can't run ps, $!\n";
  while (<PS>) {
    ($user,$pid,$cpu,$mem) = split;
  }
  close(PS);
  print "\tMemory use is $mem%.\n";

Quote:
}

=======================snip snip===============================
        Memory use is 1.6%.
Normal array created with 10141 elements
        Memory use is 11.5%.
Associative array created with 10141 elements
        Memory use is 15.2%.
Normal array undefined
        Memory use is 15.2%.
Associative array undefined
        Memory use is 15.2%.
Arrays 'a' and 'n' reset
        Memory use is 15.2%.
Normal array created with 10141 elements
        Memory use is 15.3%.
Associative array created with 10141 elements
        Memory use is 15.3%.
Normal array undefined
        Memory use is 15.3%.
Associative array undefined
        Memory use is 15.3%.
Arrays 'b' reset
        Memory use is 15.3%.

=======================snip snip===============================
--

(+31) 2154 84415/(+31) 35 833539  || Support the League for Programming Freedom!
        "If you don't know where you are going, any road will take you there."
        (Almost from) Lewis Carroll, "Alice in Wonderland".



Tue, 14 Feb 1995 21:05:41 GMT  
 memory problem with test program

:We have several perl programs that use a reasonable lot of data in (assoc)
:arrays. However, freeing those arrays does not make the memory use smaller. Is
:this perl? BSD?

Few if any implementations of UNIX support returning memory to the
operating system, and even if they did, you'd have coalescing and
garbage collection issues that would make it hard to give piece from
the malloc pool back to the OS.

--tom
--

In the common people there is no wisdom, no penetration, no power of judgment.
        --Marcus Cicero



Tue, 14 Feb 1995 22:42:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Does Perl program have problem with memory leakage?

2. problem with db tests with make test

3. Memory Fault (core dump) when running make test HELP HELP

4. memory testing with Perl

5. Memory use test

6. Good Programming Practices - Avoiding Memory Leaks

7. How to avoid memory leaks in perl programs ?

8. Finding memory leaks in a Perl program

9. Determine perl program memory usage

10. Perl/Tk memory leak example program.

11. Problems: programming serial port w/ Perl, can't find program cu

12. test for (non-)interactive program run

 

 
Powered by phpBB® Forum Software