JDK-8198226 : os::attempt_reserve_memory_at records reserved memory twice
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2018-02-15
  • Updated: 2024-12-20
  • Resolved: 2022-12-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Relates :  
Description
os::attempt_reserve_memory_at calls:

result = pd_attempt_reserve_memory_at(bytes, addr);
if (result != NULL) {
    MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC);
}

pd_attempt_reserve_memory_at calls:

os::reserve_memory, which calls:

result = pd_reserve_memory(bytes, addr, alignment_hint);
if (result != NULL) {
  MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC);
}

This has the effect that we call NMT in this sequence:
  MemTracker::record_virtual_memory_reserve(...)
  MemTracker::record_virtual_memory_reserve_and_commit(...)

After JDK-8198225 the sequence will be:
  MemTracker::record_virtual_memory_reserve(...)
  MemTracker::record_virtual_memory_reserve(...)

We should probably only be calling record_virtual_memory_reserve once when calling os::attempt_reserve_memory_at.



Comments
pd_attempt_reserve_memory_at no longer calls os::reserve_memory in any implementation. Therefore there is no longer any double accounting, so I'm closing this as Not an Issue.
20-12-2022

I realize that there are many more paths / platforms that has this problem. Maybe we should close this bug and create an RFE to clean this up?
16-02-2018