如果你坚持标准的编码在.NET中,有没有理由去手动调用GC或运行终结?如果你、没有理由、标准、NET

由网友(℡中国好男儿゛)分享简介:如果你坚持管理code和标准编码(什么,做的非常规的事情枝条CLR)在.NET中,没有任何理由手动调用GC或要求对未引用的对象上运行终结?If you stick to managed code and standard coding (nothing that does unconventional things...

如果你坚持管理code和标准编码(什么,做的非常规的事情枝条CLR)在.NET中,没有任何理由手动调用GC或要求对未引用的对象上运行终结?

If you stick to managed code and standard coding (nothing that does unconventional things withe CLR) in .NET, is there any reason to manually invoke the GC or request to run finalizers on unreferenced objects?

我想问的原因是thaty我有一个应用程序,工作记忆组的巨大增长。我想知道,如果在调用

The reason I ask is thaty I have an app that grows huge in Working Memory set. I'm wondering if calling

System.GC.Collect();

System.GC.RunFinalizers();

要帮忙的,如果它会迫使任何会不会由CLR来完成正常反正。

would help, and if it would force anything that wouldn't be done by the CLR normally anyways.

推荐答案

没有,它不会帮助。不这样做。 CLR的已经处理的好方法所有的内存管理相关的东西,并没有明确的通话将做一些它没有这样做。

No, it won't help. Don't do it. The CLR already handles all the memory management-related stuff in a fine way, and no explicit call will do something it's not already doing.

试图寻找内存泄漏的程序:在.NET语言的内存管理,但这并不意味着它总是当你不使用特定对象再认识。例如,对象附加为事件侦听器都被认为是源于通过GC进行其它的目的,并且不会被收集。

Try to look for memory leaks in your program: while .NET languages are memory-managed, it doesn't mean it always knows when you're not using a certain object anymore. For instance, objects attached as event listeners to other objects are considered rooted by the GC and won't be collected.

您可以尝试 SOS 寻求泄漏。

如果真的是有没有泄漏,那么你的程序真正需要它的内存。

If there is really no leak, then your program truly needs the memory it has.

阅读全文

相关推荐

最新文章