fork kills Inline::Javaby Sixtease (Friar)
|on Mar 20, 2008 at 17:11 UTC||Need Help??|
Sixtease has asked for the
wisdom of the Perl Monks concerning the following question:
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:
Oh and happy Easter :-)
use strict; use warnings; print "Just Another Perl Hacker\n";