如何优化WPF程序的内存占用程序

The page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.WPF性能调试系列文章:
内存监测(Ants Memory Profiler)
&&& Ants Memory Profiler是专门针对于.net程序的内存动态分析工具,通过实时监测WPF程序中每个对象分配的内存空间大小,来提供多样式报告展示内存的使用情况。我们可根据分析结果进行指定对象的优化。
& & 从RedGate官网下载,下载地址为
模拟分析应用程序
打开Ants Memory Profiler,通过菜单File -& New Profiling Session...(Ctrl+N)打开新的监测会话,在可监测程序类型中选择.Net executable。
开始执行后,wpf应用会打开执行,操作应用并实时监测内存使用情况,对于内存使用较高地方进行Take Memory Snapshot:
注:一次内存分析可进行多次内存点拍照。比如程序刚运行进行拍照,运行一段时间之后再次拍照,这样可通过对比两次拍照的内存差别分析出对象占用内存情况,更便于分析问题。
一个拍照监测点结果分析:
可参考具体详解:
注:1. 托管对象如果内存使用过高,考虑是否缓存数据过大,托管资源一般无需过多考虑,可等待.net垃圾回收器进行自行回收。
&& 2. 非托管资源如果占用内存过高,需要进行手动释放,因为费托管资源是无法自动被.net垃圾回收器回收 & 非托管资源包括:GUI+,图片操作,文件操作,win32调用等
多个拍照监测点结果对比分析:
具体类视图分析:
可参考具体详解:
具体对象分析:
可参考具体详解:
内存泄露主要原因分析:静态引用、未注销的事件绑定、非托管代码资源使用等。对于静态对象尽量小或者不用,非托管资源可通过手动Dispose来释放。
阅读(...) 评论()The page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.WPF框架的内存泄漏BUG
用户在使用GIX4某模块的过程中,内存只见加不见减。我们怀疑出现了内存泄漏,所以我花了相当一段时间来进行此问题的排查。
我使用Red Gate公司的产品ANTS Memory Profiler 5进行应用程序的内存进行监视。
用户在使用GIX4某模块的过程中,内存只见加不见减。我们怀疑出现了内存泄漏,所以我花了相当一段时间来进行此问题的排查。
我使用Red Gate公司的产品ANTS Memory Profiler 5进行应用程序的内存进行监视。并在过程中修改程序中出现的一些问题。但是最后留下一个不知道原因的引用,如图1:
图1 泄漏对象引用图
由图中可以看出,Application.Resources永久地引用了临时控件SelectionDataGrid。原因出在DeferredAppResourceReference类的Inflated事件被ResourceReferenceExpression对象引用。经查找相关资料,确定为WPF框架的BUG。该BUG会使内存不断地泄漏。
官方原文:
When a DeferredResourceReference reference is used by a ResourceReferenceExpression class, the internal Inflated event causes a strong reference to be held to the expression. This keeps the whole visual tree from being collected by the Garbage Collector after the references are removed from the tree if the DeferredResourceReference reference is never inflated.
另外,该补丁并不提供下载……汗!
BUG详见:。
版权声明:本文内容由互联网用户自发贡献,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至: 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
用云栖社区APP,舒服~
【云栖快讯】红轴机械键盘、无线鼠标等753个大奖,先到先得,云栖社区首届博主招募大赛9月21日-11月20日限时开启,为你再添一个高端技术交流场所&&
一种高性能、高可靠、可平滑扩容的分布式内存数据库服务。
充分利用阿里云现有资源管理和服务体系,引入中间件成熟的整套分布式计算框架,以应用为中心,帮助企业级客户轻松构建并...
高速通道(ExpressConnect)是一款便捷高效的网络服务,用于在云上的不同网络环境间实现高速、稳定、安全...
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效率,降低 IT 成本...
阿里云双11狂欢,不只是5折
Loading...The page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.

我要回帖

更多关于 查看程序内存占用 的文章

 

随机推荐