< prev index next >

test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java

8217332: JTREG: Clean up, use generics instead of raw types

*** 69,81 **** * Test that all SoftReferences has been cleared at time of OOM. */ void softReferencesOom(long minSize, long maxSize) { System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize ); ! LinkedList<SoftReference> arrSoftRefs = new LinkedList(); staticRef = arrSoftRefs; ! LinkedList arrObjects = new LinkedList(); staticRef = arrObjects; long multiplier = maxSize - minSize; long numberOfNotNulledObjects = 0; --- 69,81 ---- * Test that all SoftReferences has been cleared at time of OOM. */ void softReferencesOom(long minSize, long maxSize) { System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize ); ! LinkedList<SoftReference<byte[]>> arrSoftRefs = new LinkedList<>(); staticRef = arrSoftRefs; ! LinkedList<byte[]> arrObjects = new LinkedList<>(); staticRef = arrObjects; long multiplier = maxSize - minSize; long numberOfNotNulledObjects = 0; ***************
*** 87,97 **** System.out.println("num Soft: " + numSofts); while (numSofts-- > 0) { int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier)) + (int)minSize; ! arrSoftRefs.add(new SoftReference(new byte[allocationSize])); } System.out.println("free: " + Runtime.getRuntime().freeMemory()); // provoke OOME. --- 87,97 ---- System.out.println("num Soft: " + numSofts); while (numSofts-- > 0) { int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier)) + (int)minSize; ! arrSoftRefs.add(new SoftReference<byte[]>(new byte[allocationSize])); } System.out.println("free: " + Runtime.getRuntime().freeMemory()); // provoke OOME. ***************
*** 104,114 **** // Clear allocated ballast, so we don't get another OOM. staticRef = null; arrObjects = null; long oomSoftArraySize = arrSoftRefs.size(); ! for (SoftReference sr : arrSoftRefs) { Object o = sr.get(); if (o != null) { numberOfNotNulledObjects++; } --- 104,114 ---- // Clear allocated ballast, so we don't get another OOM. staticRef = null; arrObjects = null; long oomSoftArraySize = arrSoftRefs.size(); ! for (SoftReference<byte[]> sr : arrSoftRefs) { Object o = sr.get(); if (o != null) { numberOfNotNulledObjects++; }
< prev index next >