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: lmesnik
  • Loading branch information
Ramkumar Sunderbabu authored and lmesnik committed Aug 25, 2022
1 parent 76ee549 commit 7b81a9c
Show file tree
Hide file tree
Showing 50 changed files with 69 additions and 1,320 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 jdk.test.whitebox.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, 2020, 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 @@ -31,10 +31,8 @@
*
* @library /vmTestbase
* /test/lib
* @run main/othervm/native
* -XX:-UseGCOverheadLimit
* gc.lock.LockerTest
* -gp1 randomString
* -lockers jni
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.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, 2020, 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 @@ -31,10 +31,8 @@
*
* @library /vmTestbase
* /test/lib
* @run main/othervm/native
* -XX:-UseGCOverheadLimit
* gc.lock.LockerTest
* -gp1 randomString
* -lockers jniGlobalRef
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.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.

3 comments on commit 7b81a9c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 7b81a9c Nov 29, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7b81a9c Nov 29, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-7b81a9c7 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7b81a9c7 from the openjdk/jdk repository.

The commit being backported was authored by Ramkumar Sunderbabu on 25 Aug 2022 and was reviewed by Leonid Mesnik.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-7b81a9c7:GoeLin-backport-7b81a9c7
$ git checkout GoeLin-backport-7b81a9c7
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-7b81a9c7

Please sign in to comment.