【C#】内存问题汇总
一、关闭窗体内存不释放
[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); } }
/*******相与枕藉乎舟中,不知东方之既白*******/