<div dir="ltr"><div dir="ltr">Em ter., 1 de ago. de 2023 às 22:19, Brian S O'Neill <<a href="mailto:bronee@gmail.com">bronee@gmail.com</a>> escreveu:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2023-08-01 05:53 PM, Maurizio Cimadamore wrote:<br>
> <br>
> But I'd like to ask a control question: let's assume that <br>
> Bits::reserveMemory was free (or that we found some way to make it much <br>
> less expensive), would opinion then shift towards having a single JDK <br>
> parameter to control all off-heap memory allocation?<br>
> <br>
> Or is it still the case that, as Arena can be customized, custom arenas <br>
> might decide to track memory how they wish, and we should not bias the <br>
> API against this or that particular way of tracking memory usage ?<br>
> <br>
<br>
My understanding is that the reserveMemory call is primarily intended to <br>
manage off-heap memory which should be cleaned up via garbage <br>
collection. It can force full collections to help free up memory, which <br>
is generally a bad thing. Memory which isn't automatically freed <br>
shouldn't be tracked in a fashion that makes it look like running a full <br>
GC would have any effect. The MaxDirectMemorySize parameter should only <br>
apply to memory which is automatically managed.<br>
</blockquote></div><br clear="all"><div>About limiting, I agree that this limit still makes for a unified notion of GC collected native memory (direct byte buffers, the global arena etc.), since we need the JVM`s help to impose useful limits, if we want any. Memory explicitly deallocated by the programmer can be limited by the programmer however she sees fit.</div><div><br></div><div>About tracking, I am unsure, as that supports not only limiting, but monitoring. In my own practice, monitoring native memory usage is something we do using system level tools, not JVM internal counters. I have never encountered the need to measure specifically the "direct buffer memory" of a running JVM. If I had to guess, I would guess that people monitoring this specifically are concerned with the effects of encountering the limit -- something which users of deterministic or custom arenas would not need to worry about.</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>