Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A java application I'm using keeps crashing, when I had a problem with a similar application I managed to fix it by allocating more of my RAM to Java. How do I do that?

(I recently upgraded to 16 GB RAM, after installing Java.)

I'm on an iMac running Mac OSX 10.6.6.

share|improve this question
java -Xmx1024M -Xms1024M -jar *filename*.jar

Xmx is the max amount you want to allocate (in MB) and the Xms is the initial amount. You can replace the 1024 with the amount you prefer.

share|improve this answer
    
can i change it to permanently increase the RAM given to java whenever i run call a .jar file? – Kirstin Apr 12 '11 at 7:53
    
@Bec, no, you can't do this across the board to any .jar. – jzd Apr 12 '11 at 11:01
    
@Bec The only way I could think that you could do that is IDE specific. I use NetBeans and I know you can edit NetBean's config file and tell it to use more RAM. I assume you could do the same with other IDE's. But as for setting a specific amount using the command line, I believe jzd is correct. – Ryan Apr 12 '11 at 17:10
    
Also, this is only for .JAR applications that can be run headless, without GUI. for applications that cannot, you are screwed. does JAVA have a magnificent solution for this since it cannot be set across the board (which is fairly stupid IMO for above mentioned reason...)? – Michael Trouw May 28 '13 at 14:54
1  
@MichaelTrouw not correct, you can increase memory for any Java application, regardless whether they run headless or with a GUI. Ryan's solution is JAVA's standard way to increase the memory. That said you should bear in mind that a lot of application server and IDE's come with their own config file to pass the -Xmx argument to the JVM. Check the documentation of your software vendor. – Stefan Haberl Sep 5 '13 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .