托管代码也会内存泄露,唉,有什么文章介绍哪些地方容易出现内存泄露么,如何防止内存泄露
Hi,
你可以参考这个帖子的回答,里面有一些检测的方法:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/f3a3faa3-f1b3-4348-944c-43f11c339423
内存泄露的确是个问题,而且也有很多确认了的issue。我的建议是按照楼上的写法通过using等保证及时释放。如果你需要进行一些消耗大量内存的操作,你可以考虑WeakReference。
参考:
http://msdn.microsoft.com/en-us/library/ms404247.aspx
有一些内存泄露问题只存在于Debug模式你切换成Release模式就会好了。
Aaron MSDN Community Support | Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.
实现
IDisposable
接口;
使用Using语句块来释放你的对象
using(...) { }