Search code examples
javamemory-managementjvmjvm-argumentsjvm-hotspot

Why is the deafult maximum heap size so small


according to oracle's ergonomics for java 8 (also true for java 5 and beyond) The heap is maxed at the lowest of either 1Gb or 1/4th of the total physical memory. Why is that?

I have a statefull web server tht handles requests from over 1000 users a day that runs on a VM that only launches this application. For legacy reasons, this web server has to stay statefull and the object's held in the HttpSessions can be quite memory intensive. Thus, 1GB is not nearly enough.

Should modern web servers really never use more than 1GB of heap? Why should 3/4 of the machine's memory not be used?


Solution

  • The heap is maxed at the lowest of either 1Gb or 1/4th of the total physical memory. Why is that?

    Because 64MB was found to be too little on modern machines.

    Should modern web servers really never use more than 1GB of heap?

    There is no reason to take the default value of a general purpose executable as having anything much to say about best practice for web servers.

    Why should 3/4 of the machine's memory not be used?

    The assumption is that java isn't the only process on the machine. If it is the most important process on the machine and requires more memory, the user can change the default.