in reply to Memory usage in Perl.
In more specific context, there are not two variables called "name" in memory when your module is used. Perl uses garbage collection, which is (some say) simplistically implemented by a reference count. When a variable's reference count goes to 0, it is "destroyed" and the memory it used is given back to perl - not to the system - to be reused. Assuming you haven't returned a reference to your $name, that instance of the variable was destroyed when function A exited.
It may be possible perl will reuse that memory space for Function B, or it may allocate more. I do not know how aggressive perl is in its memory recycling and it still really depends on the flow of your code and how it is used.
You can also see perldoc perlobj ( search on garbage ) for a better description of the collection algorithm.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Memory usage in Perl.
by tilly (Archbishop) on Aug 07, 2000 at 08:25 UTC |