Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed duplicate System.gc() in test #18339

Merged
merged 8 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ public static boolean isFinalized(String name) {

protected static void thoroughGCandFinalization() {
System.gc();
System.gc();
System.runFinalization();
System.runFinalization();
Copy link
Member

@pshipton pshipton Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitripivkine Do we still need to call runFinaliization() and do the additional System.gc()? According to our doc update the finalization should occur from the single System.gc() now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitripivkine Do we still need to call runFinaliization() and do the additional System.gc()? According to our doc update the finalization should occur from the single System.gc() now.

In theory your statement is correct. However I don't know the reason why we call System.gc() and System.runFinalization() multiple times. I guess there is a reason. We can try to simplify this code (calling System.gc() twice?) and watch for intermittent failures.

System.gc();
System.gc();
System.runFinalization();
System.runFinalization();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ protected void setUp() throws Exception {
public final void testGetLastGcInfo() {
AssertJUnit.assertTrue(gcb instanceof com.sun.management.GarbageCollectorMXBean);
System.gc();
System.gc();
AssertJUnit.assertTrue(((com.sun.management.GarbageCollectorMXBean)gcb).getLastGcInfo() != null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ private void runTest(byte[] classBytes, String className) {
new RuntimeException("Error calling method: getCondy()" + e);
}
System.gc();
System.gc();
try {
Method condyMethod = condyClass.getDeclaredMethod("getCondy");
Object result2 = "Result2 initial value";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
public class CreateDumps {

public static void main(String[] args) {
System.gc();
System.gc();
com.ibm.jvm.Dump.HeapDump();
com.ibm.jvm.Dump.SystemDump();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ public void runTest() throws Exception {

protected static void thoroughGCandFinalization() {
System.gc();
System.gc();
System.runFinalization();
System.runFinalization();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as TestObject.java, do we still need to call runFinaliization() and do the additional System.gc()? According to our doc update the finalization should occur from the single System.gc() now.

System.gc();
System.gc();
System.runFinalization();
System.runFinalization();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public HashCodeTestParent(int mode) {
public void gc() {
switch (mode) {
case MODE_SYSTEM_GC:
System.gc();
System.gc();
break;
case MODE_SCAVENGE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ static public void testGCFlattenedPoint2DArray() throws Throwable {
Array.set(arrayObject, i, point2D);
}

System.gc();
System.gc();

Object value = Array.get(arrayObject, 0);
Expand All @@ -354,7 +353,6 @@ static public void testGCFlattenedValueArrayWithSingleAlignment() throws Throwab
Array.set(array, i, object);
}

System.gc();
System.gc();

for (int i = 0; i < 4; i++) {
Expand All @@ -371,7 +369,6 @@ static public void testGCFlattenedValueArrayWithObjectAlignment() throws Throwab
Array.set(array, i, object);
}

System.gc();
System.gc();

for (int i = 0; i < 4; i++) {
Expand All @@ -388,7 +385,6 @@ static public void testGCFlattenedValueArrayWithLongAlignment() throws Throwable
Array.set(array, i, object);
}

System.gc();
System.gc();

for (int i = 0; i < genericArraySize; i++) {
Expand All @@ -405,7 +401,6 @@ static public void testGCFlattenedLargeObjectArray() throws Throwable {
Array.set(arrayObject, i, largeObjectRef);
}

System.gc();
System.gc();

Object value = Array.get(arrayObject, 0);
Expand All @@ -416,14 +411,12 @@ static public void testGCFlattenedMegaObjectArray() throws Throwable {
Object arrayObject = Array.newInstance(megaObjectValueClass, 4);
Object megaObjectRef = createMegaObject(new Object());

System.gc();
System.gc();

for (int i = 0; i < 4; i++) {
Array.set(arrayObject, i, megaObjectRef);
}
System.gc();
System.gc();

Object value = Array.get(arrayObject, 0);
}
Expand Down Expand Up @@ -2188,7 +2181,6 @@ static public void testCreateLargeNumberOfPoint2D() throws Throwable {
MethodHandle makePoint2DX = lookup.findStatic(point2DXClass, "makeValueGeneric", MethodType.methodType(Object.class, Object.class, Object.class));
if (0 == (valueIndex % 100)) {
System.gc();
System.gc();
}
}
}
Expand Down Expand Up @@ -2556,7 +2548,6 @@ static public void testValueWithLongAlignmentGCScanning() throws Throwable {
longAlignmentArrayList.add(newLongAlignmentArray);
}

System.gc();
System.gc();

for (int i = 0; i < objectGCScanningIterationCount; i++) {
Expand All @@ -2582,7 +2573,6 @@ static public void testValueWithObjectAlignmentGCScanning() throws Throwable {
objectAlignmentArrayList.add(newObjectAlignmentArray);
}

System.gc();
System.gc();

for (int i = 0; i < objectGCScanningIterationCount; i++) {
Expand All @@ -2608,7 +2598,6 @@ static public void testValueWithSingleAlignmentGCScanning() throws Throwable {
singleAlignmentArrayList.add(newSingleAlignmentArray);
}

System.gc();
System.gc();

for (int i = 0; i < objectGCScanningIterationCount; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ public static void main(String[] args)
_array = null;
System.gc();
System.gc();
System.gc();
flooxo marked this conversation as resolved.
Show resolved Hide resolved
long tempMem = runtime.totalMemory();
System.gc();
System.gc();
System.gc();
long tempMem2 = runtime.totalMemory();

if (verbose)
Expand Down