On Wed, 25 Nov 2020, at 12:44 PM, Viktor Kojouharov wrote: > > Hi, > > Is there a way to set a hard limit on the max heap size a process is allowed > to consume, from within it? > It's almost never a problem for a process to consume as much memory as is > available, however, I've ran into real-life cases in a k8s environment, where > a pod with a Go process will get evicted, when the pod approaches the memory > limit of the node it's on. > > Reducing GOGC improves the situation, however it doesn't act as a limit. And > depending on the amount of data that's going through the process, it will > still get evicted when it saturates the memory. I could also slow the whole > process down, giving the GC even more time to reclaim the memory, but that > sounds like a big workaround.
You may be interested in this issue, which also links to several relevant ones <https://github.com/golang/go/issues/42805>https://github.com/golang/go/issues/42805 The short answer is that there is currently no way to set a hard limit but there are discussions in progress on the best approach to handle the situation you describe. -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/88cffd97-5e93-4e07-b59f-9e18c47ab94b%40www.fastmail.com.