in reply to Is there a way to invoke perl's garbage collector?

Perl uses reference counting, not garbage collection. Everything is freed as soon as there is no reference to it.

Any memory freed by Perl might not be returned to the OS, but it will become available to Perl for reuse.

Update: For example,

print("Check size of process $$ and press ENTER."); # 1676K <STDIN>; $a .= ' ' for 1..100_000; print("Check size of process $$ and press ENTER."); # 1920K <STDIN>; undef $a; $a .= '!' for 1..100_000; print("Check size of process $$ and press ENTER."); # 1920K <STDIN>;

Replies are listed 'Best First'.
Re^2: Is there a way to invoke perl's garbage collector?
by Anonymous Monk on Mar 07, 2006 at 20:43 UTC
    Thanks. I understand that the memory is available for use by perl, otherwise it would push the stack past 256MB (size of a segment or PTHREAD_STACK_MAX) which in my case is causing perl to core when creating a DOM in XML::LibXML. I'm having to limit the amount of raw xml I convert to a DOM tree to avoid this, but I'd like to reduce my in_use pages during proccessing if at all possible and that won't happen if perl does not truly free the memory. Thoughts?
        Thanks...that was a good read. I should clarify a bit. It's in XML::LibXML that this occurs which is in libxml2, so I expect that perl is not at fault here.