How to interpret the HeapReleased decrease?

127 views
Skip to first unread message

Vitaly Isaev

unread,
Jun 18, 2022, 9:35:11 AM6/18/22
to golang-nuts
Hi everyone, I've read the thread https://github.com/golang/go/issues/33376,
but still I can't figure out what does it mean when HeapReleased value is decreasing.
When the Go runtime returns the memory to the OS, isn't it an irreversible process? So why does this indicator have to go down?

Or should we interpret HeapReleased as an amount of HeapIdle virtual memory, that is not backed by physical memory?

Could anyone please elaborate on this.


Ian Lance Taylor

unread,
Jun 18, 2022, 8:02:54 PM6/18/22
to Vitaly Isaev, golang-nuts
HeapReleased goes up when the runtime tells the OS that it no longer
needs the memory. On Linux this is done via madvise(MADV_FREE).
HeapReleased goes down when the runtime decides that it wants to use
the memory again. Linux permits ths for MADV_FREE pages, it's just
that the pages may or may be zeroed.

In other words, no, in general returning memory to the OS is not an
irreversible process.

Ian

Vitaly Isaev

unread,
Jun 19, 2022, 3:57:11 AM6/19/22
to golang-nuts
Ian, thank you for the clarification, but what if this happens on Linux with Go >= 1.16 (where MADV_DONTNEED is default)?

воскресенье, 19 июня 2022 г. в 03:02:54 UTC+3, Ian Lance Taylor:

Ian Lance Taylor

unread,
Jun 20, 2022, 1:55:02 AM6/20/22
to Vitaly Isaev, golang-nuts
On Sun, Jun 19, 2022 at 12:57 AM Vitaly Isaev <vitaly...@gmail.com> wrote:
>
> Ian, thank you for the clarification, but what if this happens on Linux with Go >= 1.16 (where MADV_DONTNEED is default)?

For purposes of this discussion I don't think there is any relevant
difference in behavior.

Ian


> воскресенье, 19 июня 2022 г. в 03:02:54 UTC+3, Ian Lance Taylor:
>>
>> On Sat, Jun 18, 2022 at 6:35 AM Vitaly Isaev <vitaly...@gmail.com> wrote:
>> >
>> > Hi everyone, I've read the thread https://github.com/golang/go/issues/33376,
>> > but still I can't figure out what does it mean when HeapReleased value is decreasing.
>> > When the Go runtime returns the memory to the OS, isn't it an irreversible process? So why does this indicator have to go down?
>> >
>> > Or should we interpret HeapReleased as an amount of HeapIdle virtual memory, that is not backed by physical memory?
>> >
>> > Could anyone please elaborate on this.
>>
>> HeapReleased goes up when the runtime tells the OS that it no longer
>> needs the memory. On Linux this is done via madvise(MADV_FREE).
>> HeapReleased goes down when the runtime decides that it wants to use
>> the memory again. Linux permits ths for MADV_FREE pages, it's just
>> that the pages may or may be zeroed.
>>
>> In other words, no, in general returning memory to the OS is not an
>> irreversible process.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/41176b53-4ccc-4a61-b178-94306aba404an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages