Super Java Host
  1. Home
  2. Guides
  3. JVM heap calculator

JVM heap size calculator

Enter the RAM of your server and what runs on it. Get a safe -Xmx and -Xms, the memory left for the database and the operating system, and the exact lines to paste.

HeapOS
-Xmx (maximum heap)
-
-Xms (start heap)
-
Metaspace limit
-
Database buffers
-
Left for OS and cache
-
Collector
-



How the numbers are chosen

The heap is only part of a JVM process. Metaspace, thread stacks, the code cache and native buffers add 300 to 600 MB on top, and the operating system needs memory for its file cache. So we give the heap a fixed share of RAM: 45% when a database runs on the same server, 60% when it does not. The database gets 15% for its buffers (innodb_buffer_pool_size for MySQL and MariaDB, shared_buffers for PostgreSQL). The rest stays free for everything else.

If you know the live data after a full garbage collection, enter it. A healthy heap is at least 2.5 times that. If the result is below it, the calculator tells you which server size you need.

Reference table

Server RAMHeap with databaseHeap without databaseTypical use
2 GBabout 900 MBabout 1.2 GBOne small API or WAR
4 GBabout 1.8 GBabout 2.4 GBLight production
8 GBabout 3.6 GBabout 4.8 GBProduction with database, WildFly or Payara
16 GBabout 7.2 GBabout 9.6 GBSeveral applications
32 GBabout 14.4 GBabout 19.2 GBBusy applications
64 GBabout 28.8 GBabout 38.4 GBVery large workloads

Notes

  • WildFly and Payara use 500 to 700 MB before your application loads. Use 4 GB as a minimum for them.
  • These are starting points. Measure under real load, then adjust. See JVM heap settings.
  • If the service dies without a Java error, the server ran out of memory. See fix OutOfMemoryError.
  • The calculation runs in your browser. Nothing is sent to us.

Your own Java server, billed monthly

Plans from €15.30 a month. Set up for you, or run for you.