New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: mark long lived objects with a special flag #17047

Open
dlsniper opened this Issue Sep 9, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@dlsniper
Contributor

dlsniper commented Sep 9, 2016

Hi,

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.

Thank you.

@randall77

This comment has been minimized.

Contributor

randall77 commented Sep 9, 2016

I suspect this proposal is a bit of overkill to find memory leaks. If you have a serious memory leak (actual heap size >> heap size you expect), a random live object is old with good probability.

@randall77 randall77 added this to the Unplanned milestone Sep 9, 2016

@dlsniper

This comment has been minimized.

Contributor

dlsniper commented Sep 11, 2016

@randall77 thanks for your reply.

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.

@ALTree ALTree changed the title from Mark long lived objects with a special flag to runtime: mark long lived objects with a special flag Sep 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment