提交 46005a06 编写于 作者: S sherman

6541641: (fc) java/nio/channels/FileChannel/ExpandingMap.java should clean up after itself

Summary: Close channel and explicitly de-ref the mapped buffers before exit.
Reviewed-by: alanb
上级 fc0108a4
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4938372 * @bug 4938372 6541641
* @summary Flushing dirty pages prior to unmap can cause Cleaner thread to * @summary Flushing dirty pages prior to unmap can cause Cleaner thread to
* abort VM if memory system has pages locked * abort VM if memory system has pages locked
*/ */
...@@ -39,7 +39,7 @@ import java.util.ArrayList; ...@@ -39,7 +39,7 @@ import java.util.ArrayList;
public class ExpandingMap { public class ExpandingMap {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws Exception {
int initialSize = 20480*1024; int initialSize = 20480*1024;
int maximumMapSize = 16*1024*1024; int maximumMapSize = 16*1024*1024;
...@@ -103,6 +103,13 @@ public class ExpandingMap { ...@@ -103,6 +103,13 @@ public class ExpandingMap {
} }
} }
fc.close();
// cleanup the ref to mapped buffers so they can be GCed
for (int i = 0; i < buffers.length; i++)
buffers[i] = null;
System.gc();
// Take a nap to wait for the Cleaner to cleanup those unrefed maps
Thread.sleep(1000);
System.out.println("TEST PASSED"); System.out.println("TEST PASSED");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册