Hey All
We're now running a user facing part of our infrastructure with golang. And its great! Thanks for everyones hard work making it such a pleasure to work with.
Without going into the full details of the service (we hope to open source some day) it relies on a cgo wrapper around imagemagick (
https://github.com/quirkey/magick) to do large amounts of image processing. We're seeing some weird things happen with memory as the process's RSS continues to grow and eventually starts moving into swap. Running pprof shows that the heap is much much smaller than the RSS of the process (25MB vs 500MB).
Things I'm aware of:
1) We're working with images in memory which are relatively large (some can be >10MB's in size) so the process growing in leaps with these large allocations makes sense
2) Obviously go isn't managing the cgo code's memory, but in naive testing the c side of things was able to return memory to the OS.
3) I've tried profiling and getting data (locally) with MemStats and (in a live system) with ppprof/heap.
When doing some simple testing locally I noticed running `debug.FreeOSMemory()` did end up releasing a lot of memory back to the OS.
Now after all that detail, the QUESTIONS:
1) Is it safe to run debug.FreeOSMemory() in a production system? Or am I doing it wrong?
2) Are there other flags or hints I can set to make the "background" reclaiming of memory happen faster?
3) Is there any way to trace or instrument when these background cleanups are happening?
Thanks for your help
--AQ