-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[GR-51851] Add initial support for native memory tracking. #8349
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
Conversation
… memory allocated outside java code.
… set up. add missing files
wip handle preinit clean up and add some manual labels minor cleanup and fixes Label call sites and clean up mtThread Remove virtual memory tracking code wip remove more vmem tracking code comments and refactor more small fixes, refactore, comments comment unchecked cast label Unsafe callsite. Clean up. javadoc
Thank you @christianhaeubl . I'll look over this.
I do not think there is any need to conform to exactly the same categories. If we need new ones, it should be fine to add them. If there are categories that do not apply to SVM, we can ignore them. I do think it's worth retaining any Hotspot categories that apply in SVM to make it simpler for a user that may be relying/accustomed to them. Edit: I think the changed categories in |
* library).</li> | ||
* </ul> | ||
*/ | ||
public class UntrackedNullableNativeMemory { |
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.
Why have UntrackedNullableNativeMemory
wrap UnmanagedMemorySupport
if they serve a similar purpose? Is it a concern that a caller could either call UnmanagedMemorySupport
or UntrackedNullableNativeMemory
directly to accomplish the same thing? They could even use LibC
directly, if they are determined.
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.
UnmanagedMemory
and UnmanagedMemorySupport
shouldn't be used internally. By not using it internally, it makes it easier to distinguish between code that bypasses NMT on purpose and code that accidentally uses the public API. Note that UnmanagedMemorySupport
is platform-specific and only some implementations delegate to LibC
.
Now that NMT hooks are added at a level higher than Just an idea: What if we kept the NMT code at the level of |
public void testMalloc() { | ||
assertEquals(0, getUsedMemory()); | ||
|
||
Pointer ptr = NativeMemory.malloc(WordFactory.unsigned(ALLOCATION_SIZE), NmtCategory.Code); |
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.
Is it impossible to be using theNmtCategory.Code
category concurrently with the test?
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.
Yes, as there is no JIT compilation happening.
We can't use NMT for our public API classes ( |
Pass a native memory tracking category to all relevant allocations of native memory.
f94ce19
to
c739f18
Compare
c739f18
to
bdd3c69
Compare
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.
Thank you for working on integrating this @christianhaeubl
4abbc31
to
d78fb47
Compare
d78fb47
to
0fc07e2
Compare
…ions. Partial backport of 26aa935 from oracle/graal#8349
…ions. Partial backport of 26aa935 from oracle#8349
…ions. Partial backport of 26aa935 from oracle/graal#8349
Based on #7883.
@roberttoyonaga: please review the core parts of the PR (most other changes are just minor changes):
NativeMemory
and everything else in the same packageNativeMemoryTracking
and everything else in the same packageUnfortunately, we can't add native memory tracking to
UnmanagedMemory
because it is public API. This PR still contains a few temporary changes (e.g., NMT is enabled by default at the moment) that I will remove before merging. Naming is still up for discussion as well.Regarding the NMT categories: is there any need to stick closely to the categories that HotSpot has?