非托管资源泄露
2015-11-06 21:58
302 查看
2013/08/07
现象:
RSS信息播放库运行两天后出现“内存不足”现象
BUG:
Exception:内存不足。
System.OutOfMemoryException
Stack Trace:
在 System.Drawing.Graphics.CheckErrorStatus(Int32 status)
在 System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Bitmap..ctor(Image original, Int32 width, Int32 height)
在 System.Drawing.Bitmap..ctor(Image original)
在 Nova.Rss.RssToImage.RssItemAsImg(RssItemInfo item, Int32 wndWidth, Bitmap& bmp)
在 Nova.Rss.RssToImage.RssToMultiLinesImage(RssInfo rssInfo, Int32 wndWidth, Color backColor, List`1& imgList)
在 Nova.Rss.RssToImage.RssToScreenImageIgnoreHalfWord(RssInfo rssInfo, Size wndSize, Int32 leftMargin, Color backColor, List`1& imgList)
解决过程:
使用工具:.Net Memory Profiler工具运行库,逐个接口查看内存泄漏变量及源。
资料:
http://msdn.microsoft.com/zh-cn/magazine/cc163491.aspx
结论:
对于非托管资源,要非常注意资源的释放,容易产生内存泄漏的类型有:网络连接类,文件操作类,GDI+,流,COM组件等。
现象:
RSS信息播放库运行两天后出现“内存不足”现象
BUG:
Exception:内存不足。
System.OutOfMemoryException
Stack Trace:
在 System.Drawing.Graphics.CheckErrorStatus(Int32 status)
在 System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
在 System.Drawing.Bitmap..ctor(Image original, Int32 width, Int32 height)
在 System.Drawing.Bitmap..ctor(Image original)
在 Nova.Rss.RssToImage.RssItemAsImg(RssItemInfo item, Int32 wndWidth, Bitmap& bmp)
在 Nova.Rss.RssToImage.RssToMultiLinesImage(RssInfo rssInfo, Int32 wndWidth, Color backColor, List`1& imgList)
在 Nova.Rss.RssToImage.RssToScreenImageIgnoreHalfWord(RssInfo rssInfo, Size wndSize, Int32 leftMargin, Color backColor, List`1& imgList)
解决过程:
使用工具:.Net Memory Profiler工具运行库,逐个接口查看内存泄漏变量及源。
资料:
http://msdn.microsoft.com/zh-cn/magazine/cc163491.aspx
结论:
对于非托管资源,要非常注意资源的释放,容易产生内存泄漏的类型有:网络连接类,文件操作类,GDI+,流,COM组件等。
相关文章推荐
- glob 模块
- python第二课
- iOS入门编程1--iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS支付宝集成的小坑--集成支付宝集成总结(1)
- 基本环境搭建
- Codeforces 235C Cyclical Quest(后缀自动机)
- Java API ——StringBuffer类
- Xcode 安装插件手误选择了「Skip Bundle」后需要重新允许「Load Bundle」的解决方法
- LightOJ - 1016 Brush (II)(贪心)
- poj 3415 Common Substrings(后缀数组 | 后缀自动机)
- hud5524 Subtrees 二叉树中不同节点数的字数个个数
- 数据库性能优化的方法
- ECShop模板原理
- CEF3开发者系列之JS与C++交互之二
- Android之OptionsMenu与Notification的实现
- EF| CodeFirst 代码先行
- LeJOS学习(9):一个整合传感器与马达的简单例子
- 懒猫们终究要付出代码(本领是一生的),鲸鱼们的短视(逐小利而暴死)——这么说我应该只去互联网公司:IM,云存储,邮箱(别的一概不考虑)
- linux笔记:shell基础和bash的基本功能
- java 多线程使用方法及Socket的使用