You can trap OOM if your Perl is compiled to use $^M, which your Perl probably isn't. Otherwise... if I were you I'd look into a combination of old-fashioned "sprinkle print statements everywhere" and maybe some deep magic to attach them to the start of every sub.
That said, even if you do trap OOM, just correctly calculating the size of every object (especially if you want to DTRT on hashes of hashes of arrays and the like) itself takes up a fair bit of memory, as the Devel::Size authors note. That which you ask is difficult, sir, and as someone else who occasionally runs Perl in parallel on a cluster I count myself most fortunate to not have run into this particular problem. -C. On Tue, Mar 8, 2011 at 7:52 PM, Tom Metro <[email protected]> wrote: > Some code I'm working on is triggering an out of memory error, and I'd > like to figure out what specifically is responsible. (It's a complex > system with dozens of libraries and it runs in parallel across a cluster > of machines. Running the code in a debugger isn't a practical option.) > > Any recommendation for tools to do this? > > I don't recall if the typical profiling tools record memory usage, but a > traditional profiler would be overkill for what I need. > > The ideal solution would be something that could hook the OOM exception > and dump the symbol table along with stats for how much memory each > symbol is occupying. Another useful possibility would be dumping the > call stack. > > Is it possible to trap the OOM error? I don't think a __DIE__ handler > catches it. It seems to be an unusual error in that you often see > multiple of them, as if the first few are warnings, and then eventually > it is fatal. > > -Tom > > -- > Tom Metro > Venture Logic, Newton, MA, USA > "Enterprise solutions through open source." > Professional Profile: http://tmetro.venturelogic.com/ > > _______________________________________________ > Boston-pm mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/boston-pm > _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

