From a91965a75dd2ccdcb82501483f863f853fd6f995 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Fri, 13 Jan 2023 15:08:41 +0800 Subject: [PATCH] perf: adding manual gc ensures a very small memory footprint --- STranslate/App.xaml.cs | 2 ++ STranslate/ViewModel/MainVM.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/STranslate/App.xaml.cs b/STranslate/App.xaml.cs index 16fce42..dfd23a5 100644 --- a/STranslate/App.xaml.cs +++ b/STranslate/App.xaml.cs @@ -18,6 +18,8 @@ namespace STranslate if (mutex.WaitOne(0, false)) { base.OnStartup(e); + + Util.Util.FlushMemory(); } else { diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index 8af5913..f1bb44a 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -68,6 +68,8 @@ namespace STranslate.ViewModel if (IsTopmost) return; _speech.SpeakAsyncCancelAll(); Mainwin.Hide(); + + Util.Util.FlushMemory(); }); //source speak SourceSpeakCmd = new RelayCommand((_) => true, (_) => @@ -133,7 +135,8 @@ namespace STranslate.ViewModel SmallHumpRet = string.Empty; LargeHumpRet = string.Empty; IdentifyLanguage = string.Empty; - + + Util.Util.FlushMemory(); } /// /// 打开主窗口 @@ -189,6 +192,7 @@ namespace STranslate.ViewModel /// public void ExitApp(int id) { + Util.Util.FlushMemory(); Mainwin.NotifyIcon.Dispose(); Mainwin.Close(); //语音合成销毁