Sixtease has asked for the wisdom of the Perl Monks concerning the following question:
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 :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fork kills Inline::Java
by samtregar (Abbot) on Mar 20, 2008 at 18:40 UTC | |
|
Re: fork kills Inline::Java
by jplindstrom (Monsignor) on Mar 20, 2008 at 22:39 UTC | |
|
Re: fork kills Inline::Java
by Sixtease (Friar) on Mar 21, 2008 at 07:12 UTC |