Super Java Host
  1. Home
  2. Guides
  3. How much RAM does a Java app need

How much RAM does a Java application need?

The heap is only part of what a JVM uses. Here is how to estimate the whole process and pick a server size that does not run out of memory.

The heap is not the whole process

When people size a Java server they look at -Xmx. That sets the maximum heap, where your objects live. The operating system sees the whole process, which is larger:

  • Heap: your objects, caches and session data, up to -Xmx.
  • Metaspace: loaded classes. A framework-heavy application uses 100 to 300 MB.
  • Thread stacks: about 1 MB per thread by default. 200 threads is 200 MB.
  • Code cache: compiled code, tens of MB.
  • Direct and native memory: network buffers, compression, JDBC drivers and native libraries.
  • GC overhead: bookkeeping structures of the garbage collector.

As a working rule, expect the process to use the heap plus 300 to 600 MB. If it also shares the server with Nginx, a database and the operating system, add those too.

Our split by default

For a server with a database on it we use about 45% of RAM for the JVM heap, 15% for database buffers and leave 40% for the operating system, metaspace, thread stacks and the file cache. Without a database the heap gets 60%. The bar on the price page shows this for every size.

Typical numbers

WorkloadHeapServer size
Small Spring Boot, Quarkus or Micronaut API256 to 512 MB2 GB
Tomcat with one or two WAR applications512 MB to 1 GB2 to 4 GB
Spring Boot with Hibernate and a few hundred users, database on the same server1 to 2 GB4 to 8 GB
WildFly or Payara with one application1 to 2 GB4 to 8 GB
Several applications, or large caches4 GB and up16 GB and up

These are starting points. Measure your own application under load. Look at the heap after a full garbage collection: that is the live data. Set the maximum to at least twice that.

How to measure

# process memory as the OS sees it
ps -o pid,rss,cmd -C java

# heap, metaspace and GC at a glance
jcmd <pid> GC.heap_info
jcmd <pid> VM.native_memory summary   # needs -XX:NativeMemoryTracking=summary

Signs you need more memory

  • The process is killed by the Linux OOM killer, with no Java stack trace in the log.
  • java.lang.OutOfMemoryError: Java heap space or Metaspace.
  • The garbage collector runs back to back and CPU stays high while throughput drops.
  • Swap use keeps growing.

Next: JVM heap settings explained.

Questions about Java memory

Can a Java application run in 1 GB of RAM?

A small Quarkus or Micronaut service can. A Spring Boot application is possible but tight, and Jakarta EE servers need more. We start our plans at 2 GB.

Should I set Xms equal to Xmx?

On a dedicated server, yes. The heap is allocated once, the JVM does not spend time resizing it, and you see memory problems early. More in the heap settings guide.

Last updated October 29, 2026.

Your own Java server, billed monthly

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