The Go runtime isn't aware if it's running in a pod/container/cgroup/etc. 
or not, not out of the box anyway. Also, GOMEMLIMIT=infinity (effectively) 
by default.

Are you using something like https://github.com/KimMachineGun/automemlimit? 
At least, that would also explain why you saw things change when changing 
the memory request; possibly that number was being read by automemlimit. 
(Or it could be some other package dependency adjusting these parameters at 
init time. Or it could be something changing your program's environment 
variables.)

On Friday, January 17, 2025 at 8:44:58 AM UTC-5 Felix Böwing wrote:

> We recently had the problem, that the go garbage collector ran hot on a 
> kubernetes pod and we didn’t find out why. Specs were as follows:
>
>    - heap size as reported by the GC was roughly 3GB
>    - GOGC percentage was at 100
>    - GOMEMLIMIT was set to something way above current heap size 
>    (6750MiB).
>    - kubernetes memory limit was at 9GB
>    - kubernetes memory request was at 6GB
>
> These things all looked good for me. 
>
> We found out that the problem was fixed by setting the memory request from 
> 6 to 9GB. 
>
> And here comes the question: How does the GO GC even know about the 
> requested memory? I haven't found anything in the docs or via Google. Could 
> someone point us to the section in code?
>
> It is nice that this behavior prevents avoidable OOMs, but it also puzzled 
> us for a while. 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/1a9de128-04bc-4f37-8273-e263026aae6fn%40googlegroups.com.

Reply via email to