I'm a little behind here, but this thread caught my eye:

On 5/6/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
On 5/6/07, James. L <[EMAIL PROTECTED]> wrote:
> my question is
> once the app produce the html, does the memory
> allocated by the parsed data get released to perl?
> that memory will be reused by other mod_perl app?

No, Perl doesn't work that way.  It will keep that memory allocated
for that variable unless you undef the variable explicitly.

It's my understanding that even if you explicitly undef a variable,
perl doesn't release the memory.

Here's a demonstration:

[EMAIL PROTECTED]:~$ cat memusage.pl
#!/usr/bin/perl

use GTop ();

print "Base line:\n";
print_mem();

my %squared;
foreach my $num ( 1..500_000 ) {
       $squared{ $num } = $num**2;
}

print "\nAfter using some memory:\n";
print_mem();

%squared = undef;

print "\nAfter undef'ing variable:\n";
print_mem();

sub print_mem {
       my $proc_mem = GTop->new()->proc_mem($$);
       print "size:     " . $proc_mem->size() . "\n";
       print "vsize:    " . $proc_mem->vsize() . "\n";
       print "resident: " . $proc_mem->resident() . "\n";
       print "share:    " . $proc_mem->share() . "\n";
       print "rss:      " . $proc_mem->rss() . "\n";
}


[EMAIL PROTECTED]:~$ perl memusage.pl
Base line:
size:     7180288
vsize:    7180288
resident: 2936832
share:    1916928
rss:      2932736

After using some memory:
size:     58142720
vsize:    58142720
resident: 49774592
share:    1941504
rss:      49774592

After undef'ing variable:
size:     58142720
vsize:    58142720
resident: 49774592
share:    1941504
rss:      49774592

Reply via email to