I've been thinking on how to make finding memory leaks a bit easier for Go users.
I would like to ask if it's possible to introduce a runtime flag like GODEBUG=gctrace=3 where the GC would "paint" the long lived objects that live over a long period of time in the memory of the program. Say this could be configured via GODEBUG=gctrace=3,longlived=100s which would express that the user sees the objects that are present for more than 100 seconds printed when the GC runs (the display can be done at a frequency of a few seconds apart so that it doesn't overload output in case of very large applications). An alternative would be maybe instead of a time span to configure a number of GC runs that would need to pass in order for an object to be considered old (but that would imply the user is very savvy about the GC, how it works and how the application should perform).
I know this would imply a runtime penalty but when trying to find a memory leak performance is not the priority.
What do you think? Would this be possible? If you need further details to clarify this please let me know.
The text was updated successfully, but these errors were encountered:
That is true, probably it's going to be a bit too much / too noisy. On the other hand, I can't think of another way to make things easier to spot when leaks happen. I'd be happy with having a list of objects that I can then instruct whatever tool will handle this output to ignore as I can mark them as such.
But if there are better ways to achieve this then that would be good as well.