in reply to Does Perl have garbage collection mechanism and how it performs?

Yes, perl does do GC. Variables are deallocated when all referances to them have been eliminated (beware of circular referances . . . ). However, it does not free memory to the OS until perl exits. Instead, it puts it in a pool where perl can grab more memory for future variables instead of asking the OS for some more bytes. So your program will keep that 200k allocated for perl until it exits. Fortunatly, when perl isn't using that memory, the OS will swap those pages to the hard drive (at least, in any halfway decent VM implementation). So this isn't as big a problem as it first appears.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

  • Comment on Re: Does Perl have garbage collection mechanism and how it performs?