- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- [DllImport("kernel32.dll")]
- private static extern bool SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
- //关闭窗体按钮
- private void btnReturn_Click(object sender, EventArgs e)
- {
- this.Close();
- FlushMemory();
- }
- //刷新存储器
- private static void FlushMemory()
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
- if (Environment.OSVersion.Platform == PlatformID.Win32NT)
- {
- SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
- }
- }