Perl uses reference counting to free memory appropriately. So usually things work and you don't get memory leaks. However if you create circular references (eg A refers to B refers to C refers to A), it is up to you to manually break the circle so that they can all get freed. | [reply] |
| [reply] |
If you suspect that your applications are leaking, I suggest you use Devel::Leak or Devel::Leak::Object to detect where the leakage is, and then Devel::Cycle to see where the circular references in the leaking variables/objects are.
Here's a blogpost about detecting a leakage with these tools and fixing it by jrockway, and here's a bug report that I filed detecting a leakage in a module, also using these modules.
If the circular references are there by design, they should be weakened, as pointed by eye. | [reply] |
As long as you make sure you have closures for your variables it won't be a problem. Create as few global variables as possible, use "my $variable" and use strict;.
The suggestions above are all good as well. | [reply] |