|
|
|
|
|
by xyzzy_plugh
29 days ago
|
|
I'm not sure if you are aware but there are relatively recent environment variables you can set to help contain Go memory to a fixed size. GOMEMLIMIT works very well if you set it to around 90% of available memory as a rough heuristic. You should definitely profile your application to fine tune this number (e.g. if you link with C libraries that hold large memory pools then Go doesn't account for that) but also to identify sources of spikey/leaky allocations. For example, encoding/json is notorious for it's inner sync.Pool hanging on to outsized buffers. There's usually a lot of low hanging fruit. In my experience Go can be extremely stable in terms of memory footprint at both small (~O(1MiB)) and large (~O(256GiB)) scales, and it takes only a small amount of effort. As far as GC languages go, it is by far the easiest to work with. |
|