Here are a couple of CPAN modules that you should look at just for their descriptions: Test::Memory::Cycle, and Scalar::Util, the latter specifically in reference to weaken.
It certainly appears to us that the root cause of the problem is that the program is exhausting memory. Most likely, the system begins to “thrash” as a result of this issue, and that’s physically-speaking what actually brings it to its knees. One subtle problem that I am thinking of, hence the first paragraph, is that of circular memory-references which prevent storage from being cleaned up successfully after it has been released. But, another possible problem is that storage structures such as hashes aren’t emptied before the start of the next run ... e.g. by use of undef.
One fairly easy-to-do structural rehab that I have sometimes tried, with programs that need to process a lot of files in sequence, is to put the file-scanning loop as the main program, and have it call a subroutine for each file. All of the data structures needed are made local to that one subroutine, so that everything goes away “in one swell foop” when the subroutine ends ... provided that there are no circular storage-references in play. (If any globals are needed, the subroutine in its first few statements explicitly undefs each and every one.) This is a fairly simple re-factoring to do with most existing, hairy programs, because it doesn’t attempt to restructure the main-line logic ... it merely puts it into a box.
Amazing! A down-vote, not five seconds after this posting was made! Is anyone out there, like, running a “bot” that will do this? Just askin’ ... I find it quite entertaining, really. Pathetic, but laughable ...
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||