跟踪内存泄漏。 [英] Tracking a memory leak.

查看:84
本文介绍了跟踪内存泄漏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常巨大的对象树,它拥有大约100mb

的数据。当我将top对象设置为null时,我希望.NET

框架会在某个时刻清理内存。但是,我在任务管理器上看了

,一两个小时后我看不到MemUsage列减少了

。我知道TaskManager可能不是最好的地方

,看看衡量内存使用情况的真实方法和/或
内存泄漏的存在。所以我正在寻找一个指针,看看我应该用什么看看

是否将对象设置为null确实会在某些时候释放内存。


问候

解决方案

弗兰克,


您应该在这里查看性能指标,看看

.NET的内存消耗是。您应该查看.NET CLR Memory

类别。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


Frank Rizzo < no ** @non.comwrote in message

news:OP ************** @ TK2MSFTNGP05.phx.gbl ...
< blockquote class =post_quotes>
>我有一个非常巨大的对象树,它拥有大约100mb的
数据。当我将top对象设置为null时,我希望.NET框架能够在某个时刻清理内存。但是,我正在查看任务管理器,即使一两小时后,我也看不到MemUsage列减少了。我知道TaskManager可能不是最好的地方,看看什么是衡量内存使用和/或内存泄漏的真实方法。所以我正在寻找一个关于我应该用什么来指示是否将
对象设置为null的指针确实会在某些时候释放内存。


问候





" Frank Rizzo" < no ** @non.comwrote in message

news:OP ************** @ TK2MSFTNGP05.phx.gbl ...
< blockquote class =post_quotes>
>我有一个非常巨大的对象树,它拥有大约100mb的
数据。当我将top对象设置为null时,我希望.NET框架能够在某个时刻清理内存。但是,我正在查看任务管理器,即使一两小时后,我也看不到MemUsage列减少了。我知道TaskManager可能不是最好的地方,看看什么是衡量内存使用和/或内存泄漏的真实方法。所以我正在寻找一个关于我应该使用什么来指示是否将
对象设置为null确实会在某些时候释放内存的指针。



Process Explorer可能对你有所帮助。

http://www.microsoft.com/technet/sys...sExplorer.mspx

您可以在流程的上部窗格中右键单击并选择属性。


您也可以在下部窗格中右键单击。


5月11日下午6:03,Frank Rizzo< n ... @ none.comwrote:


我有一个非常巨大的对象树,它拥有大约100mb

的数据。当我将top对象设置为null时,我希望.NET

框架会在某个时刻清理内存。但是,我在任务管理器上看了

,一两个小时后我看不到MemUsage列减少了

。我知道TaskManager可能不是最好的地方

,看看衡量内存使用情况的真实方法和/或
内存泄漏的存在。所以我正在寻找一个指针,我应该用什么来看看

是否将对象设置为null确实会在某些时候释放内存。



一些提醒和一个问题。


请记住垃圾收集器只会在你回收时回收内存

给它带来内存压力。也就是说,只有当你尝试分配更多的内存并且GC检测到你很短时。还要记住,如果你树中的

对象已经存在了一段时间,那么它们很可能已被提升到更高代的GC中,因此它们是

不太可能快速回收。保留的时间越长,

就越不可能快速回收。


当然,如果你的程序运行了一两个小时,并且保持

在此期间分配新对象,并且

对象树的内容_still_不会消失,那么你就有问题了。


现在的问题是:树中的任何对象是否订阅了由树外的对象生成的
事件?


I have an object tree that is pretty gigantic and it holds about 100mb
of data. When I set the top object to null, I expect that the .NET
framework will clean up the memory at some point. However, I am looking
at the Task Manager and I don''t see the MemUsage column decreasing even
after an hour or two. I know that TaskManager may not be the best place
to see what is the true way to gauge memory usage and/or presense of
memory leaks. So I am looking for a pointer on what I should use to see
whether setting an object to null really will at some point free up memory.

Regards

解决方案

Frank,

You should be looking at the performance counters here to see what the
memory consumption of .NET is. You should look at the ".NET CLR Memory"
category.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Frank Rizzo" <no**@none.comwrote in message
news:OP**************@TK2MSFTNGP05.phx.gbl...

>I have an object tree that is pretty gigantic and it holds about 100mb of
data. When I set the top object to null, I expect that the .NET framework
will clean up the memory at some point. However, I am looking at the Task
Manager and I don''t see the MemUsage column decreasing even after an hour
or two. I know that TaskManager may not be the best place to see what is
the true way to gauge memory usage and/or presense of memory leaks. So I
am looking for a pointer on what I should use to see whether setting an
object to null really will at some point free up memory.

Regards




"Frank Rizzo" <no**@none.comwrote in message
news:OP**************@TK2MSFTNGP05.phx.gbl...

>I have an object tree that is pretty gigantic and it holds about 100mb of
data. When I set the top object to null, I expect that the .NET framework
will clean up the memory at some point. However, I am looking at the Task
Manager and I don''t see the MemUsage column decreasing even after an hour
or two. I know that TaskManager may not be the best place to see what is
the true way to gauge memory usage and/or presense of memory leaks. So I
am looking for a pointer on what I should use to see whether setting an
object to null really will at some point free up memory.

Process Explorer may be of some help to you.

http://www.microsoft.com/technet/sys...sExplorer.mspx

You can right-click in the upper pane on a process and select Properties.

You can right-click in the lower-pane too.


On May 11, 6:03 pm, Frank Rizzo <n...@none.comwrote:

I have an object tree that is pretty gigantic and it holds about 100mb
of data. When I set the top object to null, I expect that the .NET
framework will clean up the memory at some point. However, I am looking
at the Task Manager and I don''t see the MemUsage column decreasing even
after an hour or two. I know that TaskManager may not be the best place
to see what is the true way to gauge memory usage and/or presense of
memory leaks. So I am looking for a pointer on what I should use to see
whether setting an object to null really will at some point free up memory.

Some reminders, and a question.

Remember that the garbage collector will reclaim memory only when you
put memory pressure on it. That is, only when you try to allocate more
memory and the GC detects that you''re short. Also remember that if the
objects in your tree have been around for a while, they have likely
been promoted into higher generations of the GC, and are therefore
less likely to be reclaimed rapidly. The longer instances stay around,
the less likely they are to be reclaimed quickly.

Of course, if your program is _running_ for an hour or two, and keeps
allocating new objects during that time, and the contents of the
object tree _still_ don''t go away, then you have a problem.

Now the question: does any of the objects in the tree subscribe to
events generated by objects outside the tree?


这篇关于跟踪内存泄漏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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