1) Don't use & when calling subroutines. And if you do, DO MAKE SURE you do not use it when calling a subroutine with no parameters! Unless you know what that means.
2) Don't use
use%{$datahash{"devinfo"}} = %devinfo;
instead. It's silly to force perl to flatten the %devinfo hash into a list, build a new has containing the data and then throw %devinfo out of window. Just take a reference.$datahash{"devinfo"} = \%devinfo;
3) Don't use the global. Pass a reference to the %datahash
for (;;) { my %datahash; ..getdevicetopoll.. ifpoll( \%datahash, $dev); print FILE dump %datahash; } ... sub ifpoll { my ($datahash, $dev) = @_; my %devinfo; my %interfaces; ## etc... ..snmp a lot of data here.. $datahash->{"devinfo"} = \%devinfo; $datahash->{"interfaces"} = \%interfaces; return; }
Neither of those changes should affect the leak though, it must be somewhere else in the code. Are you sure you are not producing any cyclic references in the part of the code you did nto show us?
In reply to Re: Massive Perl Memory Leak
by Jenda
in thread Massive Perl Memory Leak
by wagnerc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |