If you want the refcount, that is simple.
$s = "you are ".int(rand(11))." on a score of 0 to 10"; print "refcount is ".Internals::SvREFCNT($s)."\n";
result
refcount is 1
Is the refcount the correct way to figure out whats being a memory hog? maybe yes, if you trying to look for something that is overreferenced, in most of the time no. I suggest looking at Devel::LeakTrace (used it personally, it never found a SV leak, it was a malloc C leak). Next question is, are your memory problems from the perl script you are running, or from XS modules you are running? And do you have a memory leak (steady slow increase in ram over time), or are simply trying to reduce runtime ram bloat of the process?

You problems can be as simply as an array that is shifted/pushed onto and never poped/unshifted, or it can be a circular reference, or a unfixable (by you, only by p5p) interp specific bug.

You say you want to know what to undef, was your script written entirely with global and the time cost to convert it to a "use strict" script is too high for you?

Also look at Devel::Gladiator, I've never used it personally.

In reply to Re: Obtaining refcount for all variables by bulk88
in thread Obtaining refcount for all variables by perldough

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.