in reply to Massive Perl Memory Leak

I don't know much about how thread data gets garbage collected. I do know they use a lot of memory though, since every time you make a new thread it copies all of the data structures in your perl interpreter. They are not shared, except for the ones you specifically mark.

In addition, the way that memory allocated for perl structures gets returned when they go out of scope is not always intuitive. The memory typically stays allocated after the variable goes out of scope. But I don't know how this interacts with threads.

Were you using local %datahash because you thought you needed that to prevent it from being shared by threads? You can actually just use our %datahash, since nothing is shared. Each thread will have a separate copy automatically.

Replies are listed 'Best First'.
Re^2: Massive Perl Memory Leak
by wagnerc (Sexton) on Jun 12, 2007 at 22:09 UTC
    I was using local %datahash; as a cheap way of reinitializing the variable at each loop. Simply doing %datahash = (); would be functionally identical for my requirements.