File tree Expand file tree Collapse file tree 1 file changed +1
-29
lines changed
test/jdk/java/io/ObjectStreamClass Expand file tree Collapse file tree 1 file changed +1
-29
lines changed Original file line number Diff line number Diff line change 6969/*
7070 * @test id=Serial
7171 * @requires vm.gc.Serial
72- * @bug 8277072
72+ * @bug 8277072 8327180
7373 * @library /test/lib/
7474 * @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC)
7575 * @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching
7676 */
7777public class ObjectStreamClassCaching {
7878
79- /**
80- * Test methods execute in same VM and are ordered by name.
81- * We test effectiveness 1st which is sensitive to previous allocations when ZGC is used.
82- */
83- @ Test
84- public void test1CacheEffectiveness () throws Exception {
85- var list = new ArrayList <>();
86- var ref1 = lookupObjectStreamClass (TestClass1 .class );
87- var ref2 = newWeakRef ();
88- boolean oome = false ;
89- try {
90- while (!ref2 .refersTo (null )) {
91- list .add (new byte [1024 * 1024 * 1 ]); // 1 MiB chunks
92- System .out .println ("1MiB allocated..." );
93- Thread .sleep (5L );
94- }
95- } catch (OutOfMemoryError e ) {
96- // release
97- list = null ;
98- oome = true ;
99- }
100- assertFalse (oome , "WeakReference was not cleared although memory was pressed hard" );
101- assertFalse (ref1 .refersTo (null ),
102- "Cache lost entry together with WeakReference being cleared although memory was not under pressure" );
103- System .gc ();
104- Thread .sleep (100L );
105- }
106-
10779 @ Test
10880 public void test2CacheReleaseUnderMemoryPressure () throws Exception {
10981 var list = new ArrayList <>();
You can’t perform that action at this time.
0 commit comments