XP is just a number | |
PerlMonks |
unreachable memory with a non-zero reference countby Pickwick (Beadle) |
on Jun 20, 2010 at 15:49 UTC ( [id://845638]=perlquestion: print w/replies, xml ) | Need Help?? |
Pickwick has asked for the wisdom of the Perl Monks concerning the following question: Hello all, in the perl documentation I've read about some statements that could result in memory leaks, but I don't understand what the real problem is and if some code I use should be avoided because it has the same problem. I would be happy if someone could give me some advise and lighten my darkness. Let me quote: A more serious concern is that unreachable memory with a non-zero reference count will not normally get freed. Therefore, this is a bad idea: http://perldoc.perl.org/perlobj.html#Two-Phased-Garbage-Collection Is the problem that $a is declared in the block, but never assigned with something and never used elsewhere? If I would assign $a a value from somewhere and do use it somewhere else, do I have the same problem? I have code like the following:
The goal of the above is to let foo return a reference to a string, but just have to create that reference once and to use it as a return value and for logging purposes. Does this produces memory leaks like stated in the perl documentation? Thanks for your hints.
Back to
Seekers of Perl Wisdom
|
|