From 2747a64155aeb77b9cd9d34359d265422d269167 Mon Sep 17 00:00:00 2001 From: Lord-Zedd Date: Sun, 2 Feb 2020 02:22:42 -0500 Subject: [PATCH] try to reduce memory usage patch tab in particular #268 --- .../Controls/PageTemplates/Games/HaloMap.xaml.cs | 6 ++++++ .../Controls/PageTemplates/PatchControl.xaml.cs | 13 +++++++++---- src/Assembly/Windows/Home.xaml.cs | 9 +++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Assembly/Metro/Controls/PageTemplates/Games/HaloMap.xaml.cs b/src/Assembly/Metro/Controls/PageTemplates/Games/HaloMap.xaml.cs index 40ece789f..2ef196eae 100644 --- a/src/Assembly/Metro/Controls/PageTemplates/Games/HaloMap.xaml.cs +++ b/src/Assembly/Metro/Controls/PageTemplates/Games/HaloMap.xaml.cs @@ -1913,6 +1913,12 @@ public void Dispose() ExternalTabsClose(tabs, false); + _stringIdTrie = null; + + _tagEntries.Clear(); + _allTags.Entries.Clear(); + _visibleTags.Entries.Clear(); + //check for any viewvalueas dialogs that rely on this cache and close them foreach (Window w in Application.Current.Windows) { diff --git a/src/Assembly/Metro/Controls/PageTemplates/PatchControl.xaml.cs b/src/Assembly/Metro/Controls/PageTemplates/PatchControl.xaml.cs index bc08fc739..4315d94a4 100644 --- a/src/Assembly/Metro/Controls/PageTemplates/PatchControl.xaml.cs +++ b/src/Assembly/Metro/Controls/PageTemplates/PatchControl.xaml.cs @@ -804,10 +804,6 @@ private void btnExtractInfo_Click(object sender, RoutedEventArgs e) #endregion - #region Patch Convertion Functions - - #endregion - #region Patch Poking Functions private Patch currentPatchToPoke; @@ -1021,5 +1017,14 @@ private void LoadPatchToPoke() #endregion // ReSharper restore UnusedMember.Global + + public void Dispose() + { + if (currentPatch != null && currentPatch.SegmentChanges != null) + currentPatch.SegmentChanges.Clear(); + + if (currentPatchToPoke != null && currentPatchToPoke.SegmentChanges != null) + currentPatchToPoke.SegmentChanges.Clear(); + } } } \ No newline at end of file diff --git a/src/Assembly/Windows/Home.xaml.cs b/src/Assembly/Windows/Home.xaml.cs index 94144e5a8..2a8b6f1d2 100644 --- a/src/Assembly/Windows/Home.xaml.cs +++ b/src/Assembly/Windows/Home.xaml.cs @@ -671,6 +671,7 @@ public void AddPatchTabModule(string patchLocation = null) Content = (patchLocation != null) ? new PatchControl(patchLocation) : new PatchControl() }; documentManager.Children.Add(newPatchTab); + newPatchTab.Closing += PatchControl_Closing; documentManager.SelectedContentIndex = documentManager.IndexOfChild(newPatchTab); } @@ -915,5 +916,13 @@ private void HaloMap_Closing(object sender, CancelEventArgs e) mp.Dispose(); } + + private void PatchControl_Closing(object sender, CancelEventArgs e) + { + LayoutDocument ld = (LayoutDocument)sender; + PatchControl mp = (PatchControl)ld.Content; + + mp.Dispose(); + } } } \ No newline at end of file