I have a long-running, complex perl process that downloads pages, extracts a couple of strings that get stored in a hash, and continues. After the page is initially downloaded, it is stored as an array of lines. I was watching memory use on a Windows machine while it ran and after every page, the memory usage jumped 2MB, but doesn't ever go back down. Eventually, I get an access violation error and the whole thing shuts down.

It's as if the arrays aren't getting garbage collected, but I've examined the reference count just prior to the reference leaving scope and it only has one reference (using Devel::Peek Dump).

SV = RV(0x1a36f28) at 0x1b78394
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,ROK)
  RV = 0x1b78b8c
  SV = PVAV(0x1b6c41c) at 0x1b78b8c
    REFCNT = 1
    FLAGS = (PADBUSY,PADMY)
    ...

I'm not sure what else to check. The computer that is running the script only has 512MB of RAM and the memory use just climbs and climbs the longer it runs. Like I say, I'm only storing what amounts to a phone number and address from each page in a hash. There's no way that one phone number/address is taking 2MB.


In reply to Running out of Memory by nwboy74

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.