in reply to Prevent "Out of Memory" error

You can inspect individual objects with Devel::Peek but you might find GTop more useful. If installed on a system that has libgtop, it can report the total memory for any process. Calling it like so:
use Gtop; my $gtop = GTop->new(); my $mem = $gtop->proc_mem($$); # Now you can use $mem->share / $mem->rss / $mem->vsize
You could monitor these before creating new objects and check if your script is using more than a "sane" amount and quit if the threshold is reached.