I have read much about perl's garbage collection infrastructure, and I am familiar with the advantages and disadvantages of mark&sweep vs. reference counting. I understand that the reference counting takes care of most of the memory deallocation throughout the program's execution, and that upon shutdown of the interpreter, a full-on mark&sweep gc run is executed, and thus self-referential and circular-referential nodes can be collected and released to the kernel.
This makes sense to me in the context of a host program that runs an embedded interpreter, such as apache running a mod_perl system that re-uses modules and would not want to accumulate memory leaks.
But for a normal perl program, let's say a simple non-interactive script running from the command line as a seperate process, what benefit is there from doing exhaustive and time-consuming garbage collection just before exiting and after all productive work is done? When a process exits, ALL the memory is released back to the kernel - interpreter memory, program-space memory - all of it. Circular references or not. Isn't this last minute gc just a big waste of time for the cases (outside of persistent runtime environments) where any garbage would be collected?
Or am I missing something?
Your enlightenment would be most appreciated.
Thanks,
- Paul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why bother with the mark and sweep garbage collection on non-embedded interpreter shutdown?
by ikegami (Patriarch) on Jun 15, 2005 at 22:21 UTC | |
by dynamo (Chaplain) on Jun 15, 2005 at 22:51 UTC | |
|
Re: Why bother with the mark and sweep garbage collection on non-embedded interpreter shutdown?
by merlyn (Sage) on Jun 15, 2005 at 22:22 UTC | |
|
Re: Why bother with the mark and sweep garbage collection on non-embedded interpreter shutdown?
by mstone (Deacon) on Jun 16, 2005 at 00:28 UTC | |
|
Re: Why bother with the mark and sweep garbage collection on non-embedded interpreter shutdown?
by adrianh (Chancellor) on Jun 16, 2005 at 23:19 UTC |