Dear Monks,

Is there a way to prevent garbage collection in a process until the process finishes it's current work. I can block signals at the start of the process, and then enable them at completion of the cycle, and then wait for more work. Is there anything similar for garbage collection?

Most of our processes work for .11 to .25 seconds, so they are persistent but not working for a long time. Enabling the garbage collection just before the 'accept' and disabling while working would prevent losing information during the process.

Background: Originally I did something like this:

my %Account = (); my $accptr = \%Account; my $work = $input ## Whatever needed to be done my $ret = &GetAccount($accptr); my $html = &CallChildToWork($accptr,\$work);

Obviously, a lot of the work is missing and subroutine 'CallChildToWork' will call other subroutines, and that's where we got problems. It worked 100% in testing. But in production, after some random time '$accptr' would be lost in a subroutine and then return in the caller routine. We verified this with 'syslog' by logging '$accptr' on subroutine entrance and again on return. It would be there on entrance and gone on return. This never cause a failure, just missing results. Here, just a guess, that it had to do with scope and garbage collection.

We solved this by making '%Account' global, and subroutines copy between '%Account' and '%TAccount'. This works 100% in production, but requires locking and unlocking the copy process. Since a second is finite, we are limiting the number of processes and cores that can be used in production.

Thank you

"Well done is better than well said." - Benjamin Franklin


Update: Resolved!

Upon testing with Perl 5.12.2, this problem no longer exists!


In reply to Postpone garbage collection during a child process run? 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.