diff --git a/CHANGELOG.md b/CHANGELOG.md index e3281bd53..b70f392aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. - [#1757] Binary search - SWF files need to be sorted by file position - [#1803] AS3 Direct editation - Colliding catch name with other variable names / arguments - AS3 Direct editation - slow property resolving (Now up to 10 times faster compilation) +- [#1875] Garbage collect SWF and its caches after closing it ### Changed - GFX - DefineExternalImage2 no longer handled as character diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index b332abee8..a094962e7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -459,7 +459,15 @@ public final class SWF implements SWFContainerItem, Timelined { clearScriptCache(); frameCache.clear(); soundCache.clear(); - + + clearImageCache(); + clearShapeCache(); + clearAbcListCache(); + + characters = null; + characterIdTags = null; + externalImages2 = null; + timeline = null; if (dumpInfo != null) { clearDumpInfo(dumpInfo); @@ -2827,6 +2835,7 @@ public final class SWF implements SWFContainerItem, Timelined { public void clearAllCache() { characters = null; characterIdTags = null; + externalImages2 = null; timeline = null; cyclicCharacters = null; clearReadOnlyListCache(); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 349b48a4a..501c6f48a 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1618,7 +1618,7 @@ public class Main { View.checkAccess(); sourceInfos.remove(swf.sourceInfo); - mainFrame.getPanel().close(swf); + mainFrame.getPanel().close(swf); } public static void reloadFile(SWFList swf) { @@ -1645,6 +1645,7 @@ public class Main { boolean closeResult = mainFrame.getPanel().closeAll(true); if (closeResult) { sourceInfos.clear(); + System.gc(); } if (filesChangedDialog != null) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 9749f3361..afc37240a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -238,8 +238,15 @@ public abstract class MainFrameMenu implements MenuBuilder { if (swf == null) { return; } - Main.closeFile(swf.swfList); + swf = null; + Timer timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + System.gc(); + } + }, 1000); } protected boolean closeAllActionPerformed(ActionEvent evt) { @@ -248,7 +255,18 @@ public abstract class MainFrameMenu implements MenuBuilder { } if (swf != null) { - return Main.closeAll(); + boolean result = Main.closeAll(); + if (result) { + swf = null; + Timer timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + System.gc(); + } + }, 1000); + } + return result; } return false; @@ -508,7 +526,7 @@ public abstract class MainFrameMenu implements MenuBuilder { lang = null; } ByteArrayOutputStream os = new ByteArrayOutputStream(); - try (PrintStream stream = new PrintStream(os, false, "UTF-8")) { + try ( PrintStream stream = new PrintStream(os, false, "UTF-8")) { CheckResources.checkResources(stream, lang); String str = new String(os.toByteArray(), Utf8Helper.charset); editor.setText(str); @@ -1139,7 +1157,7 @@ public abstract class MainFrameMenu implements MenuBuilder { + "Jre 64bit: " + Helper.is64BitJre() + Helper.newLine + "Os 64bit: " + Helper.is64BitOs() + Helper.newLine + "Max: " + (runtime.maxMemory() / 1024 / 1024) + "MB" + Helper.newLine - + "Total: " + (runtime.totalMemory()/ 1024 / 1024) + "MB" + Helper.newLine + + "Total: " + (runtime.totalMemory() / 1024 / 1024) + "MB" + Helper.newLine + "Used: " + ((runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024) + "MB" + Helper.newLine + "Free: " + (runtime.freeMemory() / 1024 / 1024) + "MB"; ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), info);