I just hit this and thought I would share.
I have been debugging this for way too long and this is the results!
Situation: One of my apps (Windows service no less) is leaking 4k of memory at a indeterminate rate.
Cause: foreach $session (%SESSIONS)In this loop I evaluate the session info in the hash key and decide if the session is still valid, if it is not I kill the session and delete the
$session key of the hash. Look ok so far?
Wrong! every time through the loop I leaked 4k for every
past deleted session!!! the delete was not acting on the key, the data in the keys was gone but there were still keys around
Fix: foreach $session (keys %SESSIONS)I'm not sure why I was leaking every time through the loop, however there may be reasons I don't know about, but folks, WATCH THE KEYWORDS! this took quite a while to debug just because it LOOKED right. If someone knows why this would leak mem (I was only evaluating the data in the hash, the only changes to the hash was when I would try to delete a key) I would love an explination.
"Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
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.