<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Java on Opslifeuk Limited</title><link>https://opslife.co.uk/tags/java/</link><description>Recent content in Java on Opslifeuk Limited</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sat, 13 Jun 2020 17:40:34 +0100</lastBuildDate><atom:link href="https://opslife.co.uk/tags/java/index.xml" rel="self" type="application/rss+xml"/><item><title>Kubernetes Resource Limits and JVM Heap Size</title><link>https://opslife.co.uk/kubernetes/memory/</link><pubDate>Sat, 13 Jun 2020 17:40:34 +0100</pubDate><guid>https://opslife.co.uk/kubernetes/memory/</guid><description>&lt;p&gt;By default, the JVM&amp;rsquo;s &lt;code&gt;maximum heap size&lt;/code&gt; is 1/4 of the physical memory available - you can read about this &lt;a href="https://docs.oracle.com/javase/9/gctuning/parallel-collector1.htm#JSGCT-GUID-74BE3BC9-C7ED-4AF8-A202-793255C864C4"&gt;in the Oracle GC tuning guide&lt;/a&gt;. This means that if you don&amp;rsquo;t define &lt;code&gt;-Xmx&lt;/code&gt; in your JVM parameters, the container will set &lt;code&gt;1/4&lt;/code&gt; of the host memory as the &lt;code&gt;maximum heap size&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On a recent enough JVM (8u191+ and 10+), the JVM is container-aware: if you set a Kubernetes &lt;code&gt;resource limit&lt;/code&gt;, the JVM uses that limit rather than the host&amp;rsquo;s memory to size the heap. So your &lt;code&gt;maximum heap size&lt;/code&gt; becomes &lt;code&gt;1/4&lt;/code&gt; of your Kubernetes &lt;code&gt;resource limit&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>