How do I allocate more RAM to Java?
22,028
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.
Author by
Kirt
Updated on September 18, 2022Comments
-
Kirt over 1 year
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.
-
Kirt about 13 yearscan i change it to permanently increase the RAM given to java whenever i run call a .jar file?
-
mark c about 13 years@Bec, no, you can't do this across the board to any .jar.
-
Ryan about 13 years@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.
-
mickey almost 11 yearsAlso, 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...)?
-
Stefan Haberl over 10 years@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.