tags:

views:

124

answers:

3

HI, I like to know can I increase the memory of the JVM depending on my application.If yes how can I increase the JVM memory? And how can I know the size of JVM?

+2  A: 

When calling java use the -Xmx Flag for example -Xmx512m for 512 megs for the heap size. You may also want to consider the -xms flag to start the heap larger if you are going to have it grow right from the start. The default size is 128megs.

Jeff Beck
+4  A: 

When starting the JVM, two parameters can be adjusted to suit your memory needs :

-Xms<size>

specifies the initial Java heap size and

-Xmx<size>

the maximum Java heap size.

http://www.rgagnon.com/javadetails/java-0131.html

Matt
A: 

If you are using eclipse then you can do this by specifying the required size for the particular application in its Run Configuration's VM Arguments as EX: -Xms128m -Xmx512m

Or if you want all application run from your eclipse to have the same spacified size then you can specify this in the eclipse.ini file which is present in your Eclipse home directory.

To get the soze of the JVM during Runtime you can use Runtime.totalMemory() which Returns the total amount of memory in the Java virtual machine, measured in bytes.

GK