in reply to Question regarding perl memory management
It is sort of a FAQ but it might be hard to find if you really don't know anything about how Perl handles memory management.
Look at garbage collection guts and Acky Memory, then try a Super Search on reference count and have a look at the first to results.
In short, no your variable will not disappear as long as at least one reference to it is still in scope.
Perl conts the references to a value in memory and only releases it when that count goes down to 0. The initial variable gives it a reference count of 1, then the reference to the variable increases it to 2. When the initial variable goes out of scope then the refcount goes back to 1, and only if the reference goes out of scope (or is re-assigned) does the refcount reach 0 and the memory is released.
Don't worry Zigster, this is friendly Perl and not !@#$%^&* C++ we're talking about.
|
|---|