in reply to Re^6: Massive Perl Memory Leak
in thread Massive Perl Memory Leak
If it were single threaded, yes. But remember threading is still Wild West territory
That's a total red-herring. Unless you are using shared variables (and even then), there is no effective difference in running two Perl threads and running two perl processes. Each thread has its own interpreter, just as each process does. And variables allocated by each interpreter are exclusive to that interpreter.
When variables die Perl only guarantees that the varname is no longer accessible, not that anything in particular has been done with the SV's behind the scenes.
That's wrong also. Reference counting means that variables allocated at any given scope are returned to the memory pool as soon as you leave that scope(*). With most other GC mechanism, those variables would be sitting around gathering electronic dust, inassessible but unreclaimed, until low memory or some other extraordinary event causes the whole program to freeze while the garbage collector scans all the programs dataspace, heap and stack,(twice at least), checking to see what is lying around and if anything else is still referencing it.
Which makes:
In fact the whole Perl memory management philosophy seems too lacidasical.
Just about the opposite of reality. Perl's GC mechanism, reference counting, is the most eager GC mechanism possible.
The only time that falls down is if you are creating circular references--as I mentioned above.
*Unless your code has passed a reference to the variables out of that scope and they have failed to let go of those references. That is, your code has done something that necessitates retention. There are a few special exceptions to do with optimisations for function lexicals also, but if they were the root of your problem, they would be known about by now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Massive Perl Memory Leak
by wagnerc (Sexton) on Jun 13, 2007 at 21:09 UTC | |
by BrowserUk (Patriarch) on Jun 14, 2007 at 01:18 UTC |