Francois Bourgeois Francois Bourgeois - 10 months ago 62
Java Question

Which arguments stand for what in JVM memory options?

There a lot of JVM arguments that affect the JVM's memory usage like

-Xms, -Xmx, -Xns, -XX:MaxPermSize...

  • What do they do?

  • Are there any more?

  • Which one do I have to increase when I get what error (e.g.

I cannot find a good cheat sheet for them - let's create one here.

Answer Source

-Xms: this option sets the initial and minimum Java heap size.

-Xmx: This option sets the maximum Java heap size. The Java heap (the “heap”) is the part of the memory where blocks of memory are allocated to objects and freed during garbage collection.

-XX:PermSize: -XX:MaxPermSize: are used to set size for Permanent Generation. The permanent space is where are stored the class, methods, internalized strings, and similar objects used by the VM and never deallocated (hence the name).

-Xss: sets the thread stack size. Thread stacks are memory areas allocated for each Java thread for their internal use. This is where the thread stores its local execution state.

-Xns: sets the nursery size. the JRockit JVM uses a nursery when the generational garbage collection model is used, that is, when the dynamic garbage collector has determined that the generational garbage collection model should be used or when the static generational concurrent garbage collector ( -Xgc : gencon) has been selected. You can also use -Xns to set a static nursery size when running a dynamic garbage collector (-XgcPrio).

  • If you are getting java.lang.OutOfMemoryError: Java heap space than change the value of -Xmx and -Xms.

  • if you are getting java.lang.OutOfMemoryError: PermGen space than try increasing the - XX:MaxPermSize value.

  • if you are getting java.lang.StackOverflowError than try increasing the -Xss value. It may be helpful by increasing the stack size but you should have a look at your code as well.