mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
improve memory usage
Signed-off-by: Shawn Yuan (from Dev Box) <shuaiyuan@microsoft.com>
This commit is contained in:
@@ -121,6 +121,12 @@ public sealed partial class MainWindow : WindowEx, IDisposable
|
|||||||
|
|
||||||
_isVisible = false;
|
_isVisible = false;
|
||||||
RemoveGlobalMouseHook();
|
RemoveGlobalMouseHook();
|
||||||
|
|
||||||
|
// Reduce memory usage when hidden
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
GC.Collect();
|
||||||
|
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RequestHide()
|
internal void RequestHide()
|
||||||
@@ -677,6 +683,9 @@ public sealed partial class MainWindow : WindowEx, IDisposable
|
|||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool GetCursorPos(out NativePoint lpPoint);
|
private static extern bool GetCursorPos(out NativePoint lpPoint);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool SetProcessWorkingSetSize(IntPtr hProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);
|
||||||
|
|
||||||
private const int WmXbuttondown = 0x020B;
|
private const int WmXbuttondown = 0x020B;
|
||||||
|
|
||||||
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
|
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||||
|
|||||||
Reference in New Issue
Block a user