Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: provide way to disable MADV_FREE #28466

aclements opened this issue Oct 29, 2018 · 3 comments


Copy link

commented Oct 29, 2018

CL 135395 switched from MADV_DONTNEED to MADV_FREE for releasing physical memory on Linux. MADV_FREE has many performance advantages, but seems to have one downside: because it releases pages lazily, it doesn't reduce a process's RSS until the system is actually under memory pressure.

I'm concerned that this may be confusing to users, but more concerned that this may confuse automated systems that monitor RSS and/or container memory usage, particularly if those systems make decisions based on this.

We may want to provide a GODEBUG setting to fall back to MADV_DONTNEED. This will give us/users a low-overhead way to confirm if this is causing a user issue as well as a workaround if it is. And then we can collect information on problems caused by this. If they're minor, we can take this GODEBUG out in the future. If they're major, we can roll this back.

/cc @mknyszek @RLH

@aclements aclements added this to the Go1.12 milestone Oct 29, 2018


This comment has been minimized.

Copy link
Member Author

commented Oct 29, 2018

As a way to experiment with MADV_DONTNEED and MADV_FREE, I created a test program.


This comment has been minimized.

Copy link

commented Jan 2, 2019

Change mentions this issue: runtime: add GODEBUG=madvdontneed=1

@gopherbot gopherbot closed this in 22738f0 Jan 2, 2019


This comment has been minimized.

Copy link

commented Jan 3, 2019

Change mentions this issue: doc/go1.12: mention Conn.SetDeadline improvements, GODEBUG=madvdontneed=1

gopherbot pushed a commit that referenced this issue Jan 4, 2019
doc/go1.12: mention Conn.SetDeadline improvements, GODEBUG=madvdontne…

Fixes #29439
Updates #28466

Change-Id: Ifa0779a089a969f99f1a47127e23565f31eec24f
Reviewed-by: Tobias Klauser <>
Reviewed-by: Ian Lance Taylor <>
Reviewed-by: Dmitri Shuralyov <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.