Skip to content
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

add function to get total live bytes #33094

Merged
merged 1 commit into from
Dec 12, 2019
Merged

add function to get total live bytes #33094

merged 1 commit into from
Dec 12, 2019

Conversation

JeffBezanson
Copy link
Sponsor Member

The GC has this counter but AFAICT we don't expose it in any way. This can be pretty useful, since it's one of the most accurate ways to see how much memory your program is actually using.

Of course, the only way to determine actually live bytes is to do a full GC right before looking at the counter. That gives the most accurate result, but is slow and also leaves out memory used due to GC not running yet, which could be important in practice. So we need to decide whether to run GC (implemented here), or instead return live_bytes from the last GC plus the number of (possibly garbage) bytes allocated since then.

@JeffBezanson JeffBezanson added the GC Garbage collector label Aug 27, 2019
@JeffBezanson JeffBezanson added status:triage This should be discussed on a triage call needs decision A decision on this change is needed labels Nov 14, 2019
@JeffBezanson
Copy link
Sponsor Member Author

From triage: this should probably not call gc(), since that could change memory usage when we're trying to profile it.

@JeffBezanson JeffBezanson removed status:triage This should be discussed on a triage call needs decision A decision on this change is needed labels Nov 14, 2019
@JeffBezanson JeffBezanson changed the title RFC: add function to get total live bytes add function to get total live bytes Nov 14, 2019
@StefanKarpinski
Copy link
Sponsor Member

Perhaps gc could return the total number of live bytes as well and have a guarantee that it's the exact number of live bytes at the point where the collection finishes. Otherwise something could have happened between a call to GC.gc() and a call to GC.live_bytes().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants