0

JVM Default Setting : -Xms32m -Xmx128m -Xss128k -Xoss128k -XX:ThreadStackSize=128

I need change Default Heap settings and want to increase heap memory at 64gb server.

  1. what problems can occur when default settings will be changed
  2. What is the limit to increase jvm heap memory

And How Can Change these parameter of jvm

Greesh Kumar
  • 1,847
  • 3
  • 27
  • 44

2 Answers2

3

How do I change JVM default heap settings?

It depends on what you mean by the "default" settings.

  • If you mean the "default" settings as implemented by the java command, then you can override the default setting using the -Xmx... (etcetera) command line options as described by @BetaRide. However, you cannot change what the java commmand's defaults are / how they are calculated.

  • If you mean the "default" settings used by some Java-based application, then there is no general answer. Different applications specify the heap size to be used in different ways. and provide different was to change the heap size. A common mechanism is to set a $JAVA_OPTS environment variable, but that is by no means universal. Check the application documentation or read the launch script.

What problems can occur when the default settings are changed?

  • If you make the heap too small, you can cause the application to suffer OutOfMemoryErrors. Depending on how well the application is written, it will either error out (a good thing), go into a "death spiral", or get into an indeterminate state. (The last happens if the OOMEs happen on a worker thread and the thread dies. The solution is to add a default uncaught exception handler that specifically causes the application to exit whenever it sees an Error or Error subclass.)

  • If you make the heap significantly bigger than you have physical memory, then you risk making the JVM thrash virtual memory when it does a garbage collection. That leads to bad performance, and on some OSes it can lead to the OS terminating your application; e.g. see https://unix.stackexchange.com/questions/479575/why-is-the-linux-oom-killer-terminating-my-programs

  • An overly large heap can also lead to unresponsiveness during garbage collection ... simply because certain phases of the GC (or the entire GC) will "stop the world", and the length of the stoppage is bigger for a bigger heap. (In some Java GC's, it is just the size of the "new" space that matters. In others, it is the entire heap size that matters. Refer to the Oracle documentation on GC Ergonomics for more details ... depending on your Java version.)

What is the limit to increase JVM heap memory?

There are a number of relevant limits.

  • Your platform's processor architecture and OS may limit you. For instance on a 32-bit intel platform, the maximum addressible memory for a JVM process would be 2^32 bytes ... and the OS will reserve a significant amount of that for its own purposes.

  • The OS will typically limit aggregate virtual memory usage for all processes based on the amount of available physical memory and swap space.

  • Some OSes (and containers) allow the administrator (or user) to place external limits on the virtual memory used by a process or group of processes.

  • Independent of the above, there are the practical limits I mentioned above. (A heap that is too big can cause problems with responsiveness, virtual memory thrashing ... and the OOM killer.)

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

The only option you need is

java -Xmx65536m your.main.Class

To answer your questions:

  1. It's no longer limited to the default heaps size.
  2. See What is the largest possible heap size with a 64-bit JVM?
Community
  • 1
  • 1
BetaRide
  • 16,207
  • 29
  • 99
  • 177