in reply to Perl cleanup takes a long time

AFAIK the reason it's slow at cleanup is because the garbage collector is pretty slow when you have lots (over a couple of million) of objects.

(I'm talking about the collector that's only run at exit time, not the reference counting collector)

If you want to skip the exit-collector entirely, take a look at POSIX's _exit() function and be careful.

Replies are listed 'Best First'.
Re^2: Perl cleanup takes a long time
by ChrisR (Hermit) on Jun 13, 2007 at 15:27 UTC
    Thanks Joost. I had read that in the Camel book but was a little scared to do it. It just seemed dangerous. I am not using any threads in this program so if I use POSIX's _exit(), will the memory be released made available to the system? Or have I just created another problem?
    Chris Rogers
    www.pcewebs.com
      All the resources that normally get taken back, should still be taken back by the system. The issues with _exit() AFAIK are in user-space: exit handling code that doesn't get run. From the perl view, END {} blocks will not be run, file handles won't be flushed to the kernel, DESTROY methods won't be called etc.

      You'll probably be fine if you make sure to close all file & database handles before calling _exit().

      update: see also this _exit(2) manpage.