From c3199e85be45e358e704dcff23662fecbf4f8fa7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 23 Jul 2018 02:18:50 +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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/net/filebot/archive/ApacheVFS.java b/source/net/filebot/archive/ApacheVFS.java index e72097e1..abee92af 100644 --- a/source/net/filebot/archive/ApacheVFS.java +++ b/source/net/filebot/archive/ApacheVFS.java @@ -9,12 +9,13 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.vfs2.AllFileSelector; +import org.apache.commons.vfs2.CacheStrategy; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSelectInfo; import org.apache.commons.vfs2.FileSelector; -import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.FileType; -import org.apache.commons.vfs2.VFS; +import org.apache.commons.vfs2.cache.NullFilesCache; +import org.apache.commons.vfs2.impl.DefaultFileSystemManager; import net.filebot.vfs.FileInfo; import net.filebot.vfs.SimpleFileInfo; @@ -23,7 +24,7 @@ public class ApacheVFS implements ArchiveExtractor, Closeable { private static final FileSelector ALL_FILES = new AllFileSelector(); - private final FileSystemManager fsm; + private final DefaultFileSystemManager fsm; private final FileObject archive; public ApacheVFS(File file) throws Exception { @@ -31,7 +32,9 @@ public class ApacheVFS implements ArchiveExtractor, Closeable { throw new FileNotFoundException(file.getAbsolutePath()); } - this.fsm = VFS.getManager(); + this.fsm = new DefaultFileSystemManager(); + this.fsm.setCacheStrategy(CacheStrategy.MANUAL); + this.fsm.setFilesCache(new NullFilesCache()); this.archive = fsm.createFileSystem(fsm.toFileObject(file)); }