I think that the long answer and the short answer are both that Chart::Clicker is leaking memory. Maybe not leaking in its own code, but somewhere between the primary module and its dependencies, there's a leak. I don't see in your code anything that you are doing seriously wrong. When you pass to an object's constructor a reference to an array, and later let that object fall out of scope, whether or not the array is still in scope should never affect the object's ability to be destroyed, freeing up its memory. My first suspicion was that the ref to the array was somehow being tied inside the object to a class that created a circular reference. But I don't see any use of tie; just a lot of Moose. However, the dependency chain is fairly heavy, and I didn't work my way up the chain in every direction in my effort to track down the culprit.

If it were me, I would try to boil it down to an even smaller test case that demonstrates the leak, and submit it as a bug report via Chart::Clicker's RT. The author knows his code base and dependencies better than you. Certainly authors appreciate actionable reports -- ones where you've done the research and created a patch for them. And if you have the ambition to do that, I'm sure it would be welcomed. But at minimum, at least submit a report demonstrating the bad behavior.

As for a temporary fix: The time honored solution is to fork children, work work work, then let them report back, and ultimately each one exits. By instantiating your Chart::Clicker objects inside of short-lived child processes, you never get into a situation where a memory leak in Chart::Clicker has a long enough life to become a problem. It's an ugly truth, but it works.


Dave


In reply to Re: Out of memory using chart::clicker by davido
in thread Out of memory using chart::clicker by Peterpion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.