[Israel.pm] Garbage Collection Question

Shlomo Yona shlomo at cs.haifa.ac.il
Sat May 8 07:40:54 PDT 2004


On Sat, 8 May 2004, Yuval Yaari wrote:

> Will Perl automagically get rid of $file after the last line I used it in
> (in case reference count == 0, of course), or would it be better to set it
> to undef?

Depending on the scope of $file.
If $file is still in scope, then Perl's garbage collector will not touch it.
That is because there is no count 0 for that chunk of
memory.

Setting the scalar to under fill, however, be useful in some
implementations of Perl, as it will set the reference count
to 0.

-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/




More information about the Perl mailing list