in reply to Re: memory leak
in thread memory leak

thanks for the reply.
i am using strict and warnings.
i really try to avoid globals; this example is the only place i could see really eating up memory. how about this:
assuming the same code, say you took each object and passed it around:
while($i < 20000000) { @objects = getObjects(); foreach my $obj (@objects) { SomeMethod($obj); } $i += 100; } sub SomeMethod { my $obj = shift; AnotherMethod($obj); } sub AnotherMethod { my $obj = shift; }
Isn't the $obj param essentialy a hash ref? This doesn't increment the reference count in every sub does it? It should all be one reference to the same memory location, right?

Or - what if the object had a "member" that was a ref to an array of other objects, could that cause problems?:
-------------------------------- package Obj; sub new { my $class = shift; my $name = shift; my $arrayRef = shift; my $self = { NAME => $obj, ARRAY_REF => $arrayRef }; bless $self, $class; return $self; } return 1; # ex: my $obj = new Obj("x", \@arrayOfObjects);