Details
-
Bug
-
Resolution: Fixed
-
P3
-
7u6, 8
-
b91
-
generic
-
generic
-
Not verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8014126 | 8 | Staffan Larsen | P3 | Closed | Fixed | team |
Description
The test java/lang/management/MemoryMXBean/ResetPeakMemoryUsage fails with NegativeArraySizeException:
Selected memory pool:
Memory Pool name: G1 Old Gen
Type: Heap memory
Memory Usage: init = 1696595968(1656832K) used = 0(0K) committed = 1696595968(1656832K) max = 32126271488(31373312K)
Threshold: 0
Manager = [G1 Old Generation]
Before big object is allocated:
Current Usage:
Initial size = 1696595968 (1656832K)
Used size = 0
Committd size = 1696595968 (1656832K)
Max size = 32126271488 (31373312K)
Peak Usage:
Initial size = 1696595968 (1656832K)
Used size = 0
Committd size = 1696595968 (1656832K)
Max size = 32126271488 (31373312K)
----------System.err:(13/696)----------
java.lang.NegativeArraySizeException
at ResetPeakMemoryUsage.main(ResetPeakMemoryUsage.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
at java.lang.Thread.run(Thread.java:722)
Looking at the test it's obvious why this happens:
final long largeArraySize = (usage0.getMax() - usage0.getUsed()) / 10; <---- largeArraysSize ends up being 3212627148, well beyond MAX_INT
// Allocate a big array - need to allocate from the old gen
Object[][][] obj = new Object[1][1][(int) largeArraySize]; <--- Casting this to int results in -1082340148
Not Critical and a test bug.
Let's do it in 7u8.
OK Dev / nloodin
OK SQE / ctornqvi
Selected memory pool:
Memory Pool name: G1 Old Gen
Type: Heap memory
Memory Usage: init = 1696595968(1656832K) used = 0(0K) committed = 1696595968(1656832K) max = 32126271488(31373312K)
Threshold: 0
Manager = [G1 Old Generation]
Before big object is allocated:
Current Usage:
Initial size = 1696595968 (1656832K)
Used size = 0
Committd size = 1696595968 (1656832K)
Max size = 32126271488 (31373312K)
Peak Usage:
Initial size = 1696595968 (1656832K)
Used size = 0
Committd size = 1696595968 (1656832K)
Max size = 32126271488 (31373312K)
----------System.err:(13/696)----------
java.lang.NegativeArraySizeException
at ResetPeakMemoryUsage.main(ResetPeakMemoryUsage.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
at java.lang.Thread.run(Thread.java:722)
Looking at the test it's obvious why this happens:
final long largeArraySize = (usage0.getMax() - usage0.getUsed()) / 10; <---- largeArraysSize ends up being 3212627148, well beyond MAX_INT
// Allocate a big array - need to allocate from the old gen
Object[][][] obj = new Object[1][1][(int) largeArraySize]; <--- Casting this to int results in -1082340148
Not Critical and a test bug.
Let's do it in 7u8.
OK Dev / nloodin
OK SQE / ctornqvi
Attachments
Issue Links
- backported by
-
JDK-8014126 TEST_BUG: j/l/management/MemoryMXBean/ResetPeakMemoryUsage fails with NegativeArraySizeException
- Closed