Hi,
I'm using a 3rd party package in my long running perl program that is leaking memory, I properly (I think) remove the variable that contains the object when I'm done with it but it's memory does not free. Consider this example:
my $hash = {1 => 2, 3 => 4};
my $retval = \$hash;
I've been using Devel::Peek so I can see $hash has a refcount of 2. Now all I have access to is $retval in my program, how can I decrease the reference count of $hash? I haven't seemed to be able to figure out how to use SvREFCNT_dec correctly in this situation. Of course $retval has a refcount of 1, so it is correctly free'd but $hash is not because it has a refcount of 2.
This is a simplified example of course, the 3rd party module I am using gives me a hash reference that probably has circular references in it which is why it doesn't get garbage collected properly.
Thanks for any help! I can of course just wrap this program in another that restarts it whenever it's memory usage gets to be to much, but I thought I would ask if this method was available.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.