Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Restrictions for J/Link-ed Programs?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100918] Re: Restrictions for J/Link-ed Programs?
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 18 Jun 2009 04:53:06 -0400 (EDT)
  • References: <h1a9se$82a$1@smc.vnet.net>

Christian Staudt wrote:
> Hi MathGroup,
> 
> I would like to use Mathematica with J/Link as a frontend and plotting  
> environment for a computing-intensive benchmark written in Java.  
> Unfortunately, I ran into the following two (related?) problems:
> 
> a) As soon as the memory footprint of the Java process reaches about  
> 260 MB (on my Macbook) or about 320 MB (on my Linux machine), it  
> grinds to a halt. Apparently, the memory footprint is not allowed to  
> increase any further, so the garbage collector goes out of its way to  
> free memory - but will eventually fail with a "GC overhead exceeded"  
> exception.
> 
> This happens only if the program is called with J/Link. Called from  
> the command line, it runs normally since it is allowed to use more  
> memory. I tried to pass e.g.  "java -Xmx2000m ..." as an Argument to  
> ReinstallJava[CommandLine->...], but Mathematica seems to ignore or  
> override the -Xmx option.
> 
> b) The benchmark uses the linear program solver Cplex, which needs to  
> communicate with a license token server in order to work. Again, it  
> runs just fine from the command line, but not with J/Link. The  
> communication with the license server fails with a timeout.
> 
> My guess is that Mathematica puts restrictions on the linked program  
> for security reasons or similar - affecting memory usage (a) and  
> network communication (b). I could not find information on this on the  
> web.
> 
> Is my guess correct? If yes, how can these restrictions be removed?
> 
> If I cannot solve this I have to do a laborious workaround, calling  
> the Java program via Run[] ... so quick help would be very much  
> appreciated. Thank you!
> 
> Greetings,
> Christian
> 
With regard to point (a), I use the following commands to increase the 
memory available for Java:

Needs["JLink`"];

  UninstallJava[];
InstallJava[JVMArguments->"-Xmx500M"]

You can use a much higher limit in 64-bit environments, of course.

I think you need to uninstall first because Java gets loaded as the 
kernel starts up. This certainly works under Windows XP. InstallJava 
does nothing if Java is already loaded.

Regarding (b), I can't imagine Mathematica imposes any restrictions on 
the Java code - but remember, if you have set the garbage collector 
thrashing, the timeout may mean what it says!

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Re: Extracting contour values from ContourPlot
  • Next by Date: PDF re-pitch [Was: Re: What should be a simple task....]
  • Previous by thread: Restrictions for J/Link-ed Programs?
  • Next by thread: Help with Hold