Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Strange memory growth?

by fletcher_the_dog (Friar)
on Nov 07, 2003 at 21:31 UTC ( [id://305454]=note: print w/replies, xml ) Need Help??


in reply to Strange memory growth?

Check out this code. It looks like in a subroutine the clean up of lexical variables in a "if" statement is not done until after the sub exits:
use strict; package foo; our $counter = 0; sub new { my $class = shift; bless {id=>$counter++},$class; } sub DESTROY{ my $self = shift; print "DESTROYING $self->{id}\n"; } package main; test(); print "Back in main\n"; sub test{ print "Entering test\n"; if (1) { my $foo = foo->new(); } if (1) { my $foo = foo->new(); } if (1) { my $foo = foo->new(); } print "Leaving test\n"; } __OUTPUT__ Entering test Leaving test DESTROYING 0 DESTROYING 1 DESTROYING 2 Back in Main
UPDATE The point of showing this code, is that maybe it is not a memory leak, but merely a delay in clean up

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://305454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-20 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found