Runtime.getRuntime().freeMemory() with ZGC
Per Liden
per.liden at oracle.com
Fri May 28 18:50:37 UTC 2021
On 5/28/21 8:34 PM, Mike Rettig wrote:
>
>
> On Fri, May 28, 2021 at 1:16 PM Per Liden <per.liden at oracle.com
> <mailto:per.liden at oracle.com>> wrote:
>
>
>
> On 5/28/21 5:51 PM, Mike Rettig wrote:
> >
> >
> > On Fri, May 28, 2021 at 10:13 AM Per Liden <per.liden at oracle.com
> <mailto:per.liden at oracle.com>
> > <mailto:per.liden at oracle.com <mailto:per.liden at oracle.com>>> wrote:
> >
> > > Here are the command line memory settings. Soft heap isn't
> set so
> > I think
> > > that means memory can't be uncommitted.
> > >
> > > -XX:InitialHeapSize=12884901888 -XX:MaxHeapSize=32210157568
> > > -XX:MinHeapSize=12884901888
> >
> > Memory will be uncommitted with this configuration, but only
> down to
> > MinHeapSize and only memory that has been unused for
> ZUncommitDelay
> > (which defaults to 300 seconds). So, if you application is
> filling up
> > the heap regularly and no SoftMaxHeapSize is set, the
> likelihood of
> > having some memory sit unused for 300s is low and nothing will be
> > uncommitted. On the other hand, if your application were to
> idle for
> > more than ZUncommitDelay, then unused memory would be
> uncommitted.
> >
> >
> > If SoftMaxHeapSize isn't set then it defaults to MaxHeapSize
> according
> > to PrintFlagsFinal. It doesn't default to MinHeap. Is the behavior
> > different from what I see by checking the values using
> -XX:PrintFlagsFinal?
>
> I'm not sure I understand the question, but yes, SoftMaxHeapSize
> defaults to MaxHeapSize.
>
>
> In my configuration above, the SoftMaxHeapSize isn't set so it defaults
> to MaxHeapSize. I'm confused by your statement "Memory will be
> uncommitted with this configuration".
>
> 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
More information about the zgc-dev
mailing list