C# 非托管资源释放
2016-03-09 11:29
381 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace ZX.OG.ScreenShot { public class MemoryManagement { [DllImport("kernel32.dll")] public static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max); public static void FlushMemory() { try { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1); } } catch (Exception ex) { } } } }
相关文章推荐
- C# 两行代码实现 延迟加载的单例模式(线程安全)
- C# + Socket断线重连
- 使用C#和.NET 4编写的并行应用程序“多核并发编程的规则”
- 深入分析委托与事件_C#
- c# 闭包 小例
- c#自己总结的几个常用的小技巧
- C#父类强制转换成子类,子类隐式转换成父类
- C#第三方控件的使用
- C#匿名方法
- C#二进制数组的字符串形式转换为二进制Byte数组
- C#的Lambda表达式嵌套例子
- C# 新建excel
- C#读取、保存二进制数据文件
- C#读取文本文件
- C#实现压缩与解压缩
- 已Access为支持,书写一个C#写入的记录的方案
- 使用C#向ACCESS中插入数据
- 使用C#向ACCESS中插入数据(仅供参考)
- C#进行Visio二次开发之文件导出及另存Web页面
- C#用正则表达式 获取网页源代码标签的属性或值