Should I separate them?

No. My thought was that the only way I could see of explaining your results is that your initial declaration:

our %RCache = (); keys( %RCache ) = 1020;

was in a different package to your reset subroutine:

sub CheckMemoryUsage { our %RCache; ...

and that because you redeclared the hash locally to the reset sub, you were manipulating two different hashes. But that doesn't make sense as the ENTER size would then be zero.

I've been unable to reproduce your results in a simplified test:

#! perl -slw use strict; use Devel::Size qw[ total_size ]; our %cache; keys %cache = 1020; sub resetCache { our %cache; printf "Before: keys: %u size: %u\n", scalar keys %cache, total_size( \%cache ); %cache = (); printf "After: keys: %u size: %u\n", scalar keys %cache, total_size( \%cache ); } while( 1 ) { $cache{ int( rand 2**32 ) } = chr(0) x 2048; if( keys %cache >8192 ) { resetCache(); } } __END__ C:\test>junk29 Before: keys: 8193 size: 17727631 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727579 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727590 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727614 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727556 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727578 After: keys: 0 size: 131144 Before: keys: 8193 size: 17727621 After: keys: 0 size: 131144 ...

And the question was me speculating about possible scenarios.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^3: Hash memory leak: posible scope issue? by BrowserUk
in thread Hash memory leak: posible scope issue? by flexvault

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.