http://qs321.pair.com?node_id=711800


in reply to Re^4: No garbage collection for my-variables
in thread No garbage collection for my-variables

But it wouldn't be terribly hard to implement some improvements here.

Perl could keep a LRU of still-allocated but unused "large" SVs and periodically free ones that haven't been re-used in the last period of time.

Note that what might look like the easiest "fix", freeing SVs for lexical variables if they are above a certain size, could have serious draw-backs, at least on some systems. Having done something like this on Win32, this can be a great way for heap fragmentation to cause your process to run out of virtual memory. Perhaps most other systems have smarter malloc()s and so aren't susceptible, but I'm not certain of that.

It also might be tricky to pick the proper parameters for what consistutes "large" and what the right minimum duration should be before the large allocation is declared "unlikely to be re-used" and free()d.

- tye        

  • Comment on Re^5: No garbage collection for my-variables (possibilities)