I would test this on your client's version of Perl.

What you describe should work, but I know that there was a bug in some versions of Perl (sorry, I couldn't seem to track it down, nor do I have them to test, but I am pretty sure that Perl 5.005_03 was one of them) where closures like that would never get garbage collected because of a Perl bug.

I would suggest trying the above with a $req with a DESTROY method that tells you when it goes away. See if it is a problem. If it is, then there isn't much you can do about it other than clean up $req yourself and hope that the memory leak doesn't grow too fast.


In reply to Re: Closures, object destruction and memory leaks by tilly
in thread Closures, object destruction and memory leaks by mpeppler

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.