Skip to content

Commit

Permalink
8287876: The recently de-problemlisted TestTitledBorderLeak test is u…
Browse files Browse the repository at this point in the history
…nstable

Reviewed-by: psadhukhan, prr
  • Loading branch information
mrserb committed Jun 7, 2022
1 parent b7a34f7 commit bf439f8
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions test/jdk/javax/swing/border/TestTitledBorderLeak.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,32 @@
* questions.
*/

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

import javax.swing.border.TitledBorder;

/*
/**
* @test
* @bug 8204963
* @summary Verifies TitledBorder's memory leak
* @run main/othervm -Xmx10M TestTitledBorderLeak
* @library /javax/swing/regtesthelpers
* @build Util
* @run main/timeout=60/othervm -mx32m TestTitledBorderLeak
*/
public class TestTitledBorderLeak {
public static void main(String[] args) throws Exception {
int max = 100000;
long initialFreeMemory = 0L;
long currentFreeMemory;
try {
for (int i = 1; i <= max; i++) {
new TitledBorder("");
if ((i % 1000) == 0) {
System.gc();
currentFreeMemory = dumpMemoryStatus("After " + i);
if(initialFreeMemory == 0L) {
initialFreeMemory = currentFreeMemory;
} else if( currentFreeMemory < initialFreeMemory/2) {
throw new RuntimeException("Memory halved: there's a leak");
}
public final class TestTitledBorderLeak {

}
}
}catch(OutOfMemoryError e) {
// Don't think it would work; should not happen
System.gc();
throw new RuntimeException("There was OOM");
public static void main(String[] args) throws Exception {
Reference<TitledBorder> border = getTitleBorder();
int attempt = 0;
while (border.get() != null) {
Util.generateOOME();
System.out.println("Not freed, attempt: " + attempt++);
}
System.out.println("Passed");
}
private static long dumpMemoryStatus(String msg) {
Runtime rt = Runtime.getRuntime();
long freeMem = rt.freeMemory();
System.out.println(msg + ": " + freeMem + " free");
return freeMem;

private static Reference<TitledBorder> getTitleBorder() {
TitledBorder tb = new TitledBorder("");
return new WeakReference<>(tb);
}
}

5 comments on commit bf439f8

@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 bf439f8 May 30, 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 bf439f8 May 30, 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-bf439f8c 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 bf439f8c from the openjdk/jdk repository.

The commit being backported was authored by Sergey Bylokhov on 7 Jun 2022 and was reviewed by Prasanta Sadhukhan and Phil Race.

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-bf439f8c:GoeLin-backport-bf439f8c
$ git checkout GoeLin-backport-bf439f8c
# 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-bf439f8c

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on bf439f8 May 30, 2023

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on bf439f8 May 30, 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-bf439f8c in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-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 bf439f8c from the openjdk/jdk repository.

The commit being backported was authored by Sergey Bylokhov on 7 Jun 2022 and was reviewed by Prasanta Sadhukhan and Phil Race.

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/jdk11u-dev:

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

Please sign in to comment.