I can't answer the garbage collection issue except to say what you probably already know: Perl deletes objects' memory when it is no longer referenced.
However using global variables to "pass" information between subs is bad, bad, bad! Instead pass a reference to the descendant subs so it is clear where information is being used and possibly modified. If you find you are passing a lot of parameters consider using light weight object oriented techniques by simply blessing a hash into the current package then calling the descendant subs on the object:
my $obj = bless {datahash => \%datahash, ...}; $obj->sub1 (); $obj->sub2 (); ... sub sub1 { my $self = shift; $self->sub3 (wibble => 3); } ... sub sub3 { my ($self, %params) = @_; for my $key (keys %{$self->{datahash}}) { my $value = $self->{datahash}{$key} * $params->{wibble}; ... } }
and if you have trouble with getting references going ask! Writing nasty code to avoid learning a new and valuable technique will not reward you over the long run, and by the sound of it not even in the short run. You may find References quick reference helps.
In reply to Re^3: Massive Perl Memory Leak
by GrandFather
in thread Massive Perl Memory Leak
by wagnerc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |