RFR: 8337217: Port VirtualMemoryTracker to use VMATree [v32]

Afshin Zafari azafari at openjdk.org
Fri Feb 28 13:18:08 UTC 2025


On Fri, 28 Feb 2025 09:44:09 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> src/hotspot/share/nmt/memTracker.hpp line 142:
>> 
>>> 140:     if (addr != nullptr) {
>>> 141:       NmtVirtualMemoryLocker nvml;
>>> 142:       VirtualMemoryTracker::Instance::add_reserved_region((address)addr, size, stack, mem_tag);
>> 
>> I do not like:
>> 
>> `VirtualMemoryTracker::Instance::add_reserved_region`
>> 
>> with the `Instance` being repeated over and over.
>> 
>> I'd prefer `VirtualMemoryTracker::add_reserved_region` and have `Instance` be impl detail inside.
>
> The wordiness is a bit annoying. The reason that we do this is to separate the global static instance from the implementation, so that we can have many `VMT`s when testing (this is very useful). Do you have a concrete way we can refactor this such that we retain the possibility of having many VMTs and one static instance, whilst reducing the wordiness when using the code? Can this refactoring wait until after integration, as we have more classes following the same pattern that'd need to be refactored?

The `HeapReserver` and `MemoryFileTracker` classes (in different parts of the code and different PRs) also use the same syntax for it. Here the same style is used to keep similarity in Hotspot code.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20425#discussion_r1975395435


More information about the hotspot-dev mailing list