|
1 | 1 | /* |
2 | | - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
69 | 69 | /* |
70 | 70 | * @test id=Serial |
71 | 71 | * @requires vm.gc.Serial |
72 | | - * @bug 8277072 |
| 72 | + * @bug 8277072 8327180 |
73 | 73 | * @library /test/lib/ |
74 | 74 | * @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC) |
75 | 75 | * @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching |
76 | 76 | */ |
77 | 77 | public class ObjectStreamClassCaching { |
78 | 78 |
|
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 | | - |
107 | 79 | @Test |
108 | 80 | public void test2CacheReleaseUnderMemoryPressure() throws Exception { |
109 | 81 | var list = new ArrayList<>(); |
|
0 commit comments