Skip to content

Commit

Permalink
8289764: gc/lock tests failed with "OutOfMemoryError: Java heap space…
Browse files Browse the repository at this point in the history
…: failed reallocation of scalar replaced objects"

Reviewed-by: mdoerr
Backport-of: 7b81a9c75d60f6eb2727515bacfffcf7cf15e128
  • Loading branch information
Amos Shi authored and GoeLin committed Jan 30, 2024
1 parent c97f19a commit 34ea901
Show file tree
Hide file tree
Showing 50 changed files with 68 additions and 1,339 deletions.
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/TEST.quick-groups
Expand Up @@ -1557,9 +1557,9 @@ vmTestbase_vm_gc_quick = \
vmTestbase/gc/gctests/StringInternGC/StringInternGC.java \
vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java \
vmTestbase/gc/lock/jni/jnilock001/TestDescription.java \
vmTestbase/gc/lock/jniref/jnireflock04/TestDescription.java \
vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock02/TestDescription.java \
vmTestbase/gc/lock/malloc/malloclock03/TestDescription.java
vmTestbase/gc/lock/jniref/jnireflock01/TestDescription.java \
vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java \
vmTestbase/gc/lock/malloc/malloclock01/TestDescription.java

vmTestbase_vm_compiler_quick = \
vmTestbase/vm/compiler/jbe/constprop/constprop01/constprop01.java \
Expand Down
33 changes: 15 additions & 18 deletions test/hotspot/jtreg/vmTestbase/gc/lock/LockerTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,9 +22,10 @@
*/
package gc.lock;

import sun.hotspot.WhiteBox;
import nsk.share.runner.*;
import nsk.share.gc.*;
import nsk.share.gc.gp.*;
import nsk.share.gc.gp.GarbageUtils;
import nsk.share.gc.lock.*;
import nsk.share.test.ExecutionController;

Expand All @@ -33,41 +34,37 @@
*
* A number of threads is started. Each one locks and eats memory.
*/
public class LockerTest extends ThreadedGCTest implements GarbageProducerAware, GarbageProducer1Aware, LockersAware {
public class LockerTest extends ThreadedGCTest implements LockersAware {

private GarbageProducer garbageProducer;
private GarbageProducer garbageProducer1;
private Lockers lockers;
private long objectSize = 1000;

private class Worker implements Runnable {

byte[] rezerve = new byte[1024 * 1024];
private Locker locker = lockers.createLocker(garbageProducer1.create(objectSize));
byte[] rezerve = new byte[1024];
private Locker locker = lockers.createLocker(rezerve);

public Worker() {
locker.enable();
}

public void run() {
locker.lock();
GarbageUtils.eatMemory(getExecutionController(), garbageProducer);
locker.unlock();
ExecutionController stresser = getExecutionController();
// Use only 30% of the heap.
final long testMemorySize = 3 * Runtime.getRuntime().maxMemory() / 10;

while (stresser.continueExecution()) {
locker.lock();
GarbageUtils.engageGC(testMemorySize);
locker.unlock();
}
}
}

protected Runnable createRunnable(int i) {
return new Worker();
}

public void setGarbageProducer(GarbageProducer garbageProducer) {
this.garbageProducer = garbageProducer;
}

public void setGarbageProducer1(GarbageProducer garbageProducer1) {
this.garbageProducer1 = garbageProducer1;
}

public void setLockers(Lockers lockers) {
this.lockers = lockers;
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,10 +32,8 @@
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native
* -XX:-UseGCOverheadLimit
* gc.lock.LockerTest
* -gp1 randomString
* -lockers jni
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/native -Xbootclasspath/a:. -Xlog:gc=debug:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.lock.LockerTest -lockers jni -t 1
*/

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,10 +32,8 @@
* @library /vmTestbase
* /test/lib
* @run driver jdk.test.lib.FileInstaller . .
* @run main/othervm/native
* -XX:-UseGCOverheadLimit
* gc.lock.LockerTest
* -gp1 randomString
* -lockers jniGlobalRef
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/native -Xbootclasspath/a:. -Xlog:gc=debug:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.lock.LockerTest -lockers jniGlobalRef -t 1
*/

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 comment on commit 34ea901

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.