3 ms·
I wrote my first Go application that was to be run on a very Linux instance (1 GB), serving results to HTML from an in-memory map of some 150MB. The memory gro
by antaviana 8y ago
I wrote my first Go application that was to be run on a very Linux instance (1 GB), serving results to HTML from an in-memory map of some 150MB. The memory growth was really out of control, panicking with "out of memory" under even low load until I added debug.FreeOSMemory after serving each search result. Even with that, I had to change the instance to 2GB. It was a one-off excperiment, but I missed releasing memory by myself to ensure a manageable working set.
- dcu 8y agothat's called a memory leak: https://en.wikipedia.org/wiki/Memory_leak https://en.wikipedia.org/wiki/Memory_leak I've seen happening in Go multiple times when people forget to close the response body after making a http request.
- sagichmal 8y agoYour program certainly had a bug. Feel free to paste a link to it here, I may be able to debug it.
- courtf 8y agoYeah definitely a bug. I've worked on systems that allocated and freed hundreds of GB every 10 minutes, written in Go with no such issues.
- justinclift 8y agoIs the code online somewhere? It really sounds like there was something not-quite-right in there. Might not be too hard for someone with time + clue to spot it. :)