From 9b8cf463ef44cb50b8d9415bcfa90aa9f9fa1e64 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 23 Jul 2018 13:42:28 +0700 Subject: [PATCH] Possibly fix Apache VFS / junrar memory leak -> https://www.filebot.net/forums/viewtopic.php?f=6&t=6061 --- source/net/filebot/archive/ApacheVFS.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/archive/ApacheVFS.java b/source/net/filebot/archive/ApacheVFS.java index abee92af..ff309e37 100644 --- a/source/net/filebot/archive/ApacheVFS.java +++ b/source/net/filebot/archive/ApacheVFS.java @@ -15,7 +15,7 @@ import org.apache.commons.vfs2.FileSelectInfo; import org.apache.commons.vfs2.FileSelector; import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.cache.NullFilesCache; -import org.apache.commons.vfs2.impl.DefaultFileSystemManager; +import org.apache.commons.vfs2.impl.StandardFileSystemManager; import net.filebot.vfs.FileInfo; import net.filebot.vfs.SimpleFileInfo; @@ -24,7 +24,7 @@ public class ApacheVFS implements ArchiveExtractor, Closeable { private static final FileSelector ALL_FILES = new AllFileSelector(); - private final DefaultFileSystemManager fsm; + private final StandardFileSystemManager fsm; private final FileObject archive; public ApacheVFS(File file) throws Exception { @@ -32,10 +32,12 @@ public class ApacheVFS implements ArchiveExtractor, Closeable { throw new FileNotFoundException(file.getAbsolutePath()); } - this.fsm = new DefaultFileSystemManager(); - this.fsm.setCacheStrategy(CacheStrategy.MANUAL); - this.fsm.setFilesCache(new NullFilesCache()); - this.archive = fsm.createFileSystem(fsm.toFileObject(file)); + fsm = new StandardFileSystemManager(); + fsm.setCacheStrategy(CacheStrategy.MANUAL); + fsm.setFilesCache(new NullFilesCache()); + fsm.init(); + + archive = fsm.createFileSystem(fsm.toFileObject(file)); } @Override @@ -63,6 +65,7 @@ public class ApacheVFS implements ArchiveExtractor, Closeable { @Override public void close() throws IOException { archive.close(); + fsm.close(); } private static class FileFilterSelector implements FileSelector {