2

I have read various posts in stackoverflow and I am trying to figure out how to increase my heap size for my JVM. I know that the command -vmargs -Xms256m -Xmx4096m will increase the heap size. But it is not working, or I don't know how to use the command. I read that I should go to the JVM folder and type this command but I cant locate Java in my Virtual machine.

I also read that I can do it by changing the values in the eclipse.ini file but I am not able to find anything related to heapsize in my file. I can do a grep java and find out that my heap size is 324m.

Can someone guide me for where and how I should increase the heap size?

trincot
  • 317,000
  • 35
  • 244
  • 286
Rags
  • 434
  • 2
  • 6
  • 20
  • 2
    Are you trying to increase the heap size of Eclipse? Or the one of another Java application? Could it be a duplicate of [this question](http://stackoverflow.com/questions/1441373/increase-jvm-heap-size-for-scala)? – Alexis Pigeon Jun 14 '12 at 18:43
  • Those are the arguments you will need to pass to Java either when it's for Java app or for Eclipse. Secondly, I would suggest reducing the -Xmx4096M to something like 2048M, as some of platforms have limitation and might not have enough memory to allocate! – Vishal Biyani Jun 14 '12 at 18:49

3 Answers3

7

It depends on what application that you are trying to launch.

If you are running your java code from commandline using java executable, then you can simply pass these parameters as argument to java executable.

java -Xms256m -Xmx2096m <main class>

If you want increase Eclipse's JVM memory, then you can update eclipse.ini by appending following lines to the end of file.

-Xms256m
-Xmx4906m

For any software which uses JVM (like tomcat, weblogic etc), you need to follow their documentation to set JVM arguments. Usually, they will provide startup script where you will have option to set the JVM arguments.

sperumal
  • 1,499
  • 10
  • 14
4

If you are using Scala, as suggested by the tag, you use -J as a prefix to the arguments that must be passed to Java. Like this:

scala -J-Xms256m -J-Xmx4096m

This would run the interpreter with 256 megabytes of initial memory, and 4 gigabytes maximum memory.

The same thing can be used with scalac and fsc.

Now, if you are using java to run stuff, you just pass them directly:

java -Xms256m -Xmx4096m <some other stuff>

If you are using something else, please say what you are using, otherwise we can't help you.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
2

You could try this:

java -Xms64m -Xmx256m HelloWorld

Where HelloWorld is replaced with your application and the other arguments are customized to your liking!

Source: http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/

barbiepylon
  • 891
  • 7
  • 23