<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Boban C.</title>
    <description>The latest articles on DEV Community by Boban C. (@boban_c_efdfda91574c06d5).</description>
    <link>https://dev.to/boban_c_efdfda91574c06d5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4217084%2F9fe54486-fac5-4fb1-b82c-4692aa4b248b.jpg</url>
      <title>DEV Community: Boban C.</title>
      <link>https://dev.to/boban_c_efdfda91574c06d5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/boban_c_efdfda91574c06d5"/>
    <language>en</language>
    <item>
      <title>How much RAM does a Java application really need? Sizing a small server</title>
      <dc:creator>Boban C.</dc:creator>
      <pubDate>Fri, 30 Oct 2026 12:03:01 +0000</pubDate>
      <link>https://dev.to/boban_c_efdfda91574c06d5/how-much-ram-does-a-java-application-really-need-sizing-a-small-server-2dma</link>
      <guid>https://dev.to/boban_c_efdfda91574c06d5/how-much-ram-does-a-java-application-really-need-sizing-a-small-server-2dma</guid>
      <description>&lt;p&gt;When people size a Java server they look at &lt;code&gt;-Xmx&lt;/code&gt;. That sets the maximum heap, where your objects live. The operating system sees the whole process, and that is larger:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Heap:&lt;/strong&gt; your objects, caches and sessions, up to &lt;code&gt;-Xmx&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metaspace:&lt;/strong&gt; loaded classes. A framework-heavy application uses 100 to 300 MB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thread stacks:&lt;/strong&gt; about 1 MB per thread by default, so 200 threads is 200 MB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code cache:&lt;/strong&gt; compiled code, tens of MB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direct and native memory:&lt;/strong&gt; network buffers, compression, JDBC drivers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GC overhead:&lt;/strong&gt; the collector's own bookkeeping.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a working rule, the process uses the heap plus 300 to 600 MB. If Nginx, a database and the OS share the server, add those too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The split I use
&lt;/h2&gt;

&lt;p&gt;With a database on the same server I give 45% of RAM to the JVM heap, 15% to database buffers, and leave 40% for the OS, metaspace, thread stacks and file cache. Without a database the heap gets 60%.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workload&lt;/th&gt;
&lt;th&gt;Heap&lt;/th&gt;
&lt;th&gt;Server&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Small Spring Boot, Quarkus or Micronaut API&lt;/td&gt;
&lt;td&gt;256 to 512 MB&lt;/td&gt;
&lt;td&gt;2 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tomcat with one or two WARs&lt;/td&gt;
&lt;td&gt;512 MB to 1 GB&lt;/td&gt;
&lt;td&gt;2 to 4 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spring Boot with Hibernate, database on the same server&lt;/td&gt;
&lt;td&gt;1 to 2 GB&lt;/td&gt;
&lt;td&gt;4 to 8 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WildFly or Payara with one application&lt;/td&gt;
&lt;td&gt;1 to 2 GB&lt;/td&gt;
&lt;td&gt;4 to 8 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are starting points. WildFly alone used about 450 MB on my test server before any application was deployed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure, do not guess
&lt;/h2&gt;

&lt;p&gt;Look at the heap &lt;em&gt;after a full garbage collection&lt;/em&gt;: that is your live data, and the maximum should be at least 2.5 times that. Turn on GC logging and a dump on failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-Xlog:gc*:file=/var/log/myapp/gc.log:time,uptime:filecount=5,filesize=10m
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the service disappears with no Java error in the log, the Linux OOM killer took it. Check &lt;code&gt;dmesg -T | grep -i "killed process"&lt;/code&gt;. Then the heap is too big for the machine, and raising it makes things worse.&lt;/p&gt;

&lt;p&gt;I put the split into a small &lt;a href="https://www.superjavahost.com/tools/jvm-heap-calculator" rel="noopener noreferrer"&gt;JVM heap calculator&lt;/a&gt;: enter RAM, app server and database, and it prints the &lt;code&gt;-Xmx&lt;/code&gt;, &lt;code&gt;-Xms&lt;/code&gt;, metaspace and database buffer values to paste into systemd.&lt;/p&gt;

&lt;p&gt;The full version of this guide is &lt;a href="https://www.superjavahost.com/guide/how-much-ram-does-a-java-app-need" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>java</category>
      <category>jvm</category>
      <category>devops</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
