in reply to Memory usage of a "sub" in mod_perl
You could try Devel::Cycle (or Test::Memory::Cycle, or Devel::Monitor) to check if your Html::page object maybe has circular references, which would stop the memory from being freed... In that case, modules like Object::Destroyer might help to tackle the problem (unless you can get rid of the circular refs yourself otherwise).
Update: Another thing to be aware of is that even without a true memory leak (due to circular refs), there is still the issue that memory once allocated by the Perl interpreter is usually not being returned to the OS before the interpreter process terminates — though this might be somewhat OS dependent (i.e. I've heard rumours that on Windows, memory actually may be returned to the OS — not sure though).
The net effect is that - although memory is being freed and recycled Perl-internally - if you allocate a huge data structure (even if only once), the process size will stay at the maximum memory usage that ever occurred in the lifetime of the process... I think there is a way around that problem by compiling Perl with the configuration settings to not use its own memory pool, but rather have it directly use the (slower) system malloc routines — In other words, if all else fails (and you're absolutely sure you don't have a classical memory leak), this might be worth a try...
|
|---|