如何发现和处理内存问题? C# [英] How to find dispose and memory issues? C#

查看:210
本文介绍了如何发现和处理内存问题? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用内存150MB不要不久前,现在它是286mb。它缓慢上升,所以我必须忘记处置的东西。这个心不是很多,我的问题,因为我有4GB,但我想给这对其他人谁只公羊为1GB。其他然后通过代码行会由行如何找到需要处理的,或只是一般的大对象的对象?

My app was using 150mb of memory not to long ago, now it is at 286mb. It slowly rises so i must be forgetting to dispose something. This isnt much of a problem for me since i have 4gb but i want to send this to others who have only 1gb of ram. other then going through the code line by line how can i find objects that need to be disposed of or just generally large objects?

推荐答案

扩展都JP和里德的回答。

Extending both JP and Reed's answers.

我想澄清一点困惑。如果看到在存储器显著增加问题不太可能是与呼叫处置的问题。物通常用于释放像手柄非托管资源。这些不占用太多的内存,而是将作为资源更加珍贵。

I wanted to clear up a bit of confusion. If you are seeing significant increases in memory the issue is unlikely to be a problem with calling Dispose. Dispose is typically used to free up unmanaged resources like handles. These don't take up much memory but instead are more precious as resources.

在内存增加通常与大型对象或集合被访问从托管对象被通过堆栈对象或强GC手柄直接或间接相关的根深蒂固。这是你可能会希望把重点放在你的调查区域。

Increases in memory are generally associated with large objects or collections being accessible from a managed object being rooted directly or indirectly via a stack object or a strong GC handle. This is the area you will likely want to focus your investigation on.

这篇关于如何发现和处理内存问题? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆