in reply to Perl cleanup takes a long time

I wonder if it takes so long to close because you're swapping. Are you out of memory?

Replies are listed 'Best First'.
Re^2: Perl cleanup takes a long time
by varian (Chaplain) on Jun 14, 2007 at 08:09 UTC
    Perrin brings up a very good point.

    I quickly ran a test that creates 3 hashes of the type and depth that you mentioned. Here's the ps command output:

    PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 22842 pts/1 R+ 0:00 0 10 6941 1680 0.1 perl xxx.pl create all the hashes PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 22842 pts/1 S+ 0:23 2 10 932137 883884 85.5 perl xxx.pl clean out hashes PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 22842 pts/1 R+ 0:30 31 10 932137 885632 85.6 perl xxx.pl we're done

    Memory requirements of your program are likely to be at least 933 MBytes this is without DBI etc.!! Since you mentioned that your computer has 1GByte internal memory on board the sheer size of the hashes definitely will require the operating system to swap memory pages.
    The Perl garbage collection is not the cause of this problem, even while it does require some time. The operating system takes time to memory swap things in good shape again.
    So you may want to add a bit more internal memory to your system to run an application like this one ;-)

    Test-program source: