8241806: The sun/awt/shell/FileSystemViewMemoryLeak.java is unstable

Reviewed-by: jdv, aivanov
This commit is contained in:
Sergey Bylokhov 2020-11-06 00:30:09 +00:00
parent 57b98fa55a
commit e730e8b691
2 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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
@ -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 {
@ -39,6 +41,9 @@ public class FileSystemViewMemoryLeak {
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:\\");
@ -52,6 +57,10 @@ public class FileSystemViewMemoryLeak {
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));
@ -77,5 +86,9 @@ public class FileSystemViewMemoryLeak {
boolean drive = fileSystemView.isDrive(root);
}
}
private static boolean isComplete() {
return endtime - System.nanoTime() < 0;
}
}