JDK-8043476 : java/util/BitSet/BSMethods.java failed with: java.lang.OutOfMemoryError: Java heap space
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-05-19
  • Updated: 2015-01-21
  • Resolved: 2014-05-26
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.
JDK 8 JDK 9
8u40Fixed 9 b15Fixed
Related Reports
Relates :  
Description
----------System.err:(35/1564)----------
SetGetClearFlip             : Passed
Clear                       : Passed
Flip                        : Passed
Set                         : Passed
Get                         : Passed
AndNot                      : Passed
And                         : Passed
Or                          : Passed
Xor                         : Passed
Length                      : Passed
Equals                      : Passed
NextSetBit                  : Passed
NextClearBit                : Passed
Intersects                  : Passed
Cardinality                 : Passed
Empty                       : Passed
java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3308)
	at java.util.BitSet.ensureCapacity(BitSet.java:337)
	at java.util.BitSet.expandTo(BitSet.java:352)
	at java.util.BitSet.set(BitSet.java:447)
	at BSMethods.makeSet(BSMethods.java:77)
	at BSMethods.testToString(BSMethods.java:901)
	at BSMethods.main(BSMethods.java:137)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:484)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:745)

Comments
The newly added code in JDK-8040806 which triggers the OOME is: check(makeSet(Integer.MAX_VALUE-1).toString().equals( "{" + (Integer.MAX_VALUE-1) + "}")); So we are making a new BitSet for Integer.MAX_VALUE-1 bits. Integer.MAX_VALUE-1 / 64 * 8 amounts to 256MB of memory to be allocated. MaxRAM for C1 on x86 is: src/cpu/x86/vm/c1_globals_x86.hpp 56:define_pd_global(uint64_t,MaxRAM, 1ULL*G); and MaxRAMFraction is: 2045: product(uintx, MaxRAMFraction, 4, \ which amounts to: julong reasonable_max = phys_mem / MaxRAMFraction; $ /java/re/jdk/9/promoted/latest/binaries/linux-i586/fastdebug/bin/java -client -XX:+PrintGCDetails -XX:+Verbose Maximum heap size 268435456 Initial heap size 16777216 Minimum heap size 5242880 256MB of maximum heap. Do your math!
23-05-2014

There was a change to this test with JDK-8040806 and it went into 9 b13.
23-05-2014

Looking at the history of failures this test only failed on either Linux or Windows 32-bit, only -client, in both -Xmixed and -Xcomp. It started to fail with JDK9 b12.
23-05-2014