[GR-56600] Track virtual memory with native memory tracking (NMT) #8630
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.
Summary
Related Issue: #8629
This pull request adds virtual memory tracking to NMT. Previously, NMT only tracked mallocs and was missing information about virtual memory.
The main component of this PR is the
VirtualMemoryTrackerclass which is based onvirtualMemoryTracker.cppin Hotspot. Since commits and uncommits may partially (or not at all) overlap with existing committed regions, it is necessary to keep an internal model of virtual memory in use.NativeMemoryTrackingdelegates virtual memory tracking duties toVirtualMemoryTrackerwhich maintains this internal model. This is the same as howmemTracker.hppdelegates tovirtualMemoryTracker.cppin Hotspot.NativeMemoryTrackingremains the the main interface to record and retrieve tracking data, whileVirtualMemoryTrackerand associated classes are only used by NMT internally.Tracking virtual memory usage before the image heap is mapped requires special handling. We can't use the
NativeMemoryTrackingimage singleton yet so we must instead use unmanaged memory and stack memory to temporarily record virtual memory usage. Once the image heap is mapped, the temporary records can be properly committed to tracking.NmtPreImageHeapDatais used to enqueue records of pre-image-heap reserves/commits.More details:
memTracker.hppuses the same approach to protect virtual memory accounting.