Finding a Perl memory leak

前端 未结 3 1018
难免孤独
难免孤独 2020-12-19 07:07

SOLVED see Edit 2

Hello,

I\'ve been writing a Perl program to handle automatic upgrading of local (proprietary) programs (for the company I

3条回答
  •  再見小時候
    2020-12-19 07:38

    You could try using Devel::Size to profile some of your objects. e.g. in the main:: scope (the .pl file itself), do something like this:

    use Devel::Size qw(total_size);
    
    foreach my $varname (qw(varname1 varname2 ))
    {
        print "size used for variable $varname: " . total_size($$varname) . "\n";
    }
    

    Compare the actual size used to what you think is a reasonable value for each object. Something suspicious might pop out immediately (e.g. a cache that is massively bloated beyond anything that sounds reasonable).

    Other things to try:

    • Eliminate bits of functionality one at a time to see if suddenly things get a lot better; I'd start with the use of any external libraries
    • Is the bad behaviour localized to just one particular machine, or one particular operating system? Move the program to other systems to see how its behaviour changes.
    • (In a separate installation) try upgrading to the latest Perl (5.10.1), and also upgrade all your CPAN modules

提交回复
热议问题