Description
We recently noticed some OOM kills, and after a fun debugging adventure involving core dumps, we concluded that the issue was caused by our usage of the SetCrashOutput API which mirrors the example from the documentation.
In our case the parent process is subject to a GOMEMLIMIT
env variable, and the child process inherited it. This in combination with some init
functions that were spawning background goroutine activity caused the child process to grow its heap without the GC kicking in due to the high memory limit inherited from the parent process. Eventually this lead to the child+parent exceeding the memory limit of the container, resulting in an OOM kill.
Suggestion: Let's update the docs to either strip the memory limit env var or avoid passing any environment variables from the parent process (remove the os.Environ()
). I can send a patch if there is consensus behind either of those two approaches.
cc @mknyszek
Edit: The parent process was also setting GOGC=off
. That's what actually caused the OOM.