changeset 13831:62426bb0cb1b

7143743: Potential memory leak with zip provider Reviewed-by: lancea, clanger, alanb Contributed-by: Jaikiran Pai <jai.forums2013@gmail.com>
author lancea
date Wed, 15 Jan 2020 15:24:54 -0500
parents 4dd113d7811e
children 92ceaf480621
files src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Thu Jan 16 09:53:03 2020 -0800
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Wed Jan 15 15:24:54 2020 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -289,6 +289,14 @@
                 def.end();
         }
 
+        beginWrite();                // lock and sync
+        try {
+            // Clear the map so that its keys & values can be garbage collected
+            inodes = null;
+        } finally {
+            endWrite();
+        }
+
         IOException ioe = null;
         synchronized (tmppaths) {
             for (Path p: tmppaths) {