How can I access the ref count of a Perl hash?

perl

Solution

You are looking for Devel::Refcount.

Problem

I'm trying to enable the garbage collector of my script to do a better job. There's a ton of memory that it should be able to reclaim, but something is stopping it. I've used Devel::Cycle a bit and that's allowed me to get closer but I'm not quite there. How do I find out the current reference count for a Perl hash (the storage for my objects)? Is there a way to track who is holding a reference to an object? Perhaps a sort of Tie that says, whenever someone points are this object, remember who that someone is.

Original source

Related problems