Skip to content

Commit

Permalink
8241806: The sun/awt/shell/FileSystemViewMemoryLeak.java is unstable
Browse files Browse the repository at this point in the history
Reviewed-by: jdv, aivanov
  • Loading branch information
mrserb committed Nov 6, 2020
1 parent 57b98fa commit e730e8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -260,7 +260,6 @@ java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all
java/awt/print/PrinterJob/TestPgfmtSetMPA.java 8198343 generic-all
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
sun/awt/shell/FileSystemViewMemoryLeak.java 8241806 windows-all
sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java 8022403 generic-all
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180 windows-all,macosx-all
Expand Down
17 changes: 15 additions & 2 deletions test/jdk/sun/awt/shell/FileSystemViewMemoryLeak.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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 @@ -27,10 +27,12 @@
* @summary FileSystemView.isDrive(File) memory leak on "C:\" file reference
* @modules java.desktop/sun.awt.shell
* @requires (os.family == "windows")
* @run main/othervm -Xmx8m FileSystemViewMemoryLeak
* @run main/othervm/timeout=320 -Xmx8m FileSystemViewMemoryLeak
*/
import java.io.File;
import java.text.NumberFormat;
import java.util.concurrent.TimeUnit;

import javax.swing.filechooser.FileSystemView;

public class FileSystemViewMemoryLeak {
Expand All @@ -39,6 +41,9 @@ public static void main(String[] args) {
test();
}

// Will run the test no more than 300 seconds
static long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(300);

private static void test() {

File root = new File("C:\\");
Expand All @@ -52,6 +57,10 @@ private static void test() {
int iMax = 50000;
long lastPercentFinished = 0L;
for (int i = 0; i < iMax; i++) {
if (isComplete()) {
System.out.println("Time is over");
return;
}

long percentFinished = Math.round(((i * 1000d) / (double) iMax));

Expand All @@ -77,5 +86,9 @@ private static void test() {
boolean drive = fileSystemView.isDrive(root);
}
}

private static boolean isComplete() {
return endtime - System.nanoTime() < 0;
}
}

3 comments on commit e730e8b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@mrserb
Copy link
Member Author

@mrserb mrserb commented on e730e8b Feb 3, 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 e730e8b Feb 3, 2023

Choose a reason for hiding this comment

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

@mrserb Could not automatically backport e730e8b6 to openjdk/jdk11u-dev due to conflicts in the following files:

  • test/jdk/ProblemList.txt

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b mrserb-backport-e730e8b6

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk e730e8b6919e4e7879e2c702b1c3101768110973

# Backport the commit
$ git cherry-pick --no-commit e730e8b6919e4e7879e2c702b1c3101768110973
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport e730e8b6919e4e7879e2c702b1c3101768110973'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport e730e8b6919e4e7879e2c702b1c3101768110973.

Please sign in to comment.