Java™ virtual machine (JVM) heap size parameters directly influence garbage collection behavior. If you increase the heap size value, your system can process more objects before the heap size triggers a garbage collection.
The tuning of JVM heap sizes often involves a balance between the garbage collections and the time needed to perform the garbage collection. A larger heap size also means that a larger amount of time is needed to find and process objects that need to be collected.
When you plan for system memory consumption, include additional processor memory for the JVM to use outside of the heap size and random access memory (RAM) for the operating system. Include an additional 30% or 40% of memory to account for this additional processor usage.
The value of the JVM heap size is directly related to the amount of physical memory in the system. Set the initial and maximum heap sizes to 4096 to start tuning, because 64-bit operating systems have an address space limit of 4 GB, regardless of the amount of physical memory in the system.
Never set the JVM heap size larger than the physical memory in the system.