Hello friends,

I'm using a Java application from within a Perl script via Inline::Java. God bless that module. I have another Perl module that leaks huge amounts of memory and I need that one to run before the Java thing but after Java has been loaded. I need to reclaim the leaked memory before letting the Java app do its business, so I fork and do the leaking in a child process, which, after exiting, frees the memory.

What causes me grief is that after the child process ends, my Java no longer works. I attribute it to destructors that cripple my JVM when the child process deceases. Undefing DESTROY methods doesn't help. I guess it would be best to somehow invoke fresh new perl interpreter to do the dirty leaking job instead of forking but I don't know how to do it (of course it would be best to not leak but the module is not mine and it's huge, obfuscated and sui generis). Or is there a better way?

Here is a fork-enhanced snippet from perldoc Inline::Java that demonstrates my problem:

use Inline Java => <<'END_OF_JAVA_CODE' ; class Pod_alu { public Pod_alu(){ } public int add(int i, int j){ return i + j ; } } END_OF_JAVA_CODE my $alu = new Pod_alu() ; print($alu->add(9, 16) . "\n") ; if (fork == 0) { exit(0) } else { wait } print($alu->add(9, 16) . "\n") ;

Oh and happy Easter :-)

use strict; use warnings; print "Just Another Perl Hacker\n";

In reply to fork kills Inline::Java by Sixtease

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.