Slight difference of Non-heap memory usage as a Java program runs
<p>I have a simple code for a multi-threaded echo server in Java (it returns whatever received back to the clients). I'm profiling the various resources including the non-heap memory usage. I understand the non-heap memory of JVM is also created at the JVM start-up, however, stores per-class structures and includes call stacks, memory allocated by native code for instance for off-heap caching, the Metaspace as well as memory used by the JIT compiler (compiled native code). But I have two main questions: </p>

<p>1) The non-heap memory usage slightly increases as time passes. The increase is tiny, but what causes this slight increase in the memory usage?</p>

<p>2) While still the non-heap memory usage is almost identical as the number of communicating clients increases, if we zoom in a lot, similarly we notice a small increase as the number of clients increases. What is the main reason for that? I was guessing it might be due to more space required for new threads, but what do these threads do to cause this slight increase?</p>

<p>3) We notice the same difference as in 2 above for Heap memory as well. However, the difference is much more. What is the reasons for that? My guess was increased buffer size required for storing messages.</p>

<p><a href="https://i.stack.imgur.com/bKHh5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bKHh5.png" alt="enter image description here"></a></p>