Runtime.getRuntime().freeMemory() with ZGC
Per Liden
per.liden at oracle.com
Mon May 31 11:19:40 UTC 2021
On 5/28/21 10:21 PM, Mike Rettig wrote:
>
> On Fri, May 28, 2021 at 1:50 PM Per Liden <per.liden at oracle.com
> <mailto:per.liden at oracle.com>> wrote:
>
> > How is it possible for memory to be uncommitted down to MinHeapSize
> > based on the configuration I provided? Does ZGC uncommit memory
> below
> > SoftMaxHeapSize?
>
> Yes, the lower limit for uncommit is MinHeapSize, so it can uncommit
> below SoftMaxHeapSize. SoftMaxHeapSize is in this context just used
> as a
> way to make memory that it's strictly needed by the application become
> "aged" and thereby become eligible for uncommit with regards to
> ZUncommitDelay.
>
> /Per
>
>
> For my purposes, I can set min heap equal to max heap then it will work
> as I intended. I don't want memory uncommitted once it has been claimed
> by the jvm.
Ok, then you want to use -XX:-ZUncommit, that will stop ZGC from ever
uncommitting any part of the heap.
>
> However, I don't feel that I fully understand the relationships between
> the settings. In your article, what is the value of the MinHeapSize?
> Does MinHeapSize affect the behavior as described in the article? Will
> the behavior change if the min heap is equal to the max heap?
I see that my blog post wasn't very clear on that, sorry. In the example
I gave there it's assumed that MinHeapSize is set to something lower or
equal to SoftMaxHeapSize. So, MinHeapSize controls the amount of memory
that will never be uncommitted.
>
> https://malloc.se/blog/zgc-softmaxheapsize
> <https://malloc.se/blog/zgc-softmaxheapsize>
>
> As I've said in prior posts, I think ZGC (and other gc's) could be
> easier to use if the jvm options captured the goals of the users.
> Because ZGC lacks a good tuning option, I've spent a lot time
> experimenting with options trying to get the behavior I want. I never
> had to do this with G1. I just set MaxGCPauseMillis and things worked as
> I expected. The final ZGC settings that I'm using are not ideal. I've
> decided to just give ZGC more memory than I think it will ever need
> since I don't have an easy way to specify the balance of memory vs pause
> time that I would consider healthy.
Thanks for the feedback. What option would you have liked to have?
Something like G1's MaxGCPauseMillis wouldn't make sense for ZGC, since
pauses are O(1).
/Per
More information about the zgc-dev
mailing list