-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: None
-
Component/s: hotspot
-
b02
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
|---|---|---|---|---|---|---|
| JDK-8373384 | 26 | Sendao Yan | P4 | Resolved | Fixed | b28 |
In `test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java`, the relevant logic is roughly:
```
monitor.resetPeakUsage(pool);
isExceeded = monitor.isUsageThresholdExceeded(pool);
b = new byte[INCREMENT];
isExceeded = monitor.isUsageThresholdExceeded(pool);
if (peakUsed >= threshold && !isExceeded) {
isExceeded = monitor.isUsageThresholdExceeded(pool);
if (isExceeded) {
// OK
} else {
// failure
}
}
```
The intention of this test is to verify that when `peakUsed` exceeds the threshold, the result of `isUsageThresholdExceeded` should be consistent.
However, `isUsageThresholdExceeded` checks the **current usage**, not the peak usage. The `new byte[INCREMENT]` allocation may trigger a GC, which can reduce the current memory usage. As a result, the second assignment to `isExceeded` can overwrite a previously observed `true` value with `false`.
One possible fix is to avoid losing the "exceeded" observation by combining the results:
```
isExceeded = isExceeded || monitor.isUsageThresholdExceeded(pool);
```
This ensures that once the threshold is observed as exceeded, a later GC-induced drop in current usage will not mask it.
```
monitor.resetPeakUsage(pool);
isExceeded = monitor.isUsageThresholdExceeded(pool);
b = new byte[INCREMENT];
isExceeded = monitor.isUsageThresholdExceeded(pool);
if (peakUsed >= threshold && !isExceeded) {
isExceeded = monitor.isUsageThresholdExceeded(pool);
if (isExceeded) {
// OK
} else {
// failure
}
}
```
The intention of this test is to verify that when `peakUsed` exceeds the threshold, the result of `isUsageThresholdExceeded` should be consistent.
However, `isUsageThresholdExceeded` checks the **current usage**, not the peak usage. The `new byte[INCREMENT]` allocation may trigger a GC, which can reduce the current memory usage. As a result, the second assignment to `isExceeded` can overwrite a previously observed `true` value with `false`.
One possible fix is to avoid losing the "exceeded" observation by combining the results:
```
isExceeded = isExceeded || monitor.isUsageThresholdExceeded(pool);
```
This ensures that once the threshold is observed as exceeded, a later GC-induced drop in current usage will not mask it.
- backported by
-
JDK-8373384 Make isexceeded001.java more robust
-
- Resolved
-
- links to
-
Commit(jdk26)
openjdk/jdk/ec6beaa2
-
Commit(master)
openjdk/jdk/4d696d0d
-
Review(jdk26)
openjdk/jdk/28694
-
Review(master)
openjdk/jdk25u-dev/69
-
Review(master)
openjdk/jdk/28655
(1 links to)