forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implemented C# GC get heap size/ get used size #208
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joncham
reviewed
Jul 22, 2023
int[] data = new int[1024 * 1024 * 100]; | ||
GC.Collect(); | ||
long heapSizeAfterBigAlloc = ClrHost.gc_get_heap_size(); | ||
Assert.Greater(heapSizeAfterBigAlloc, heapSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try putting GC.KeepAlive(data);
at the end of the method.
joncham
approved these changes
Jul 22, 2023
…ing that GC was not ready
…mmy data allocated, and that used size is smaller than the total heap
…figure out what exception occured
…ified gc_get_used_size to use GC.GetGCMemoryInfo as there seems to be random discrepencies between GC.GetGCMemoryInfo values and GC.GetTotalMemory data (it may also be a race condition issue)
…g triggered) Removed test to check that used memory is less or equal to total memory, since this is likely to cause instabilities if the GC kicks in between the calls, as it seems like it happened in prior tests.
Ok finally got everything stable (fingers crossed) tests passed on the last 3 runs (aside from one build timeout, unrelated). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Would love some input regarding the tests.
They are very approximative, but should be stable. I can't unfortunately check for a precise size, as far as I know.
Edit: turns out they are not as stable as I thought... thanks Yamato 😓 .
Does anyone have a suggestion for a better test?