VB.net表单关闭和内存释放 [英] VB.net Form Closing and memory releasing

查看:142
本文介绍了VB.net表单关闭和内存释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我正在写一个(VS2008,.Net_framework 3.5,VB.net)应用程序



当我关闭一个内存使用量很大的表单时,我检查 Taskmanager

并发现它(表单)没有释放所有内存分配了,我尝试了很多方法,但我认为所有这些都不是正确的,因为问题仍然存在,或者我可能没有抓住正确的方法。 [例如:GC.collect,Me = nothing,Me.dispose,GC.SuppressFinalize(Me)..等;引自网络。 ]



我的问题是:这是一个/正确的免费方式(因为我没有探查器)来检查应用程序的内存使用情况..



如何释放为表格分配的所有内存





非常感谢

解决方案

使用TaskManager完成的估算非常不可靠,不应该考虑在内。它显示的不是真正分配的内存。如果你终止某个进程,甚至是非托管,所有内存都会被回收,期间。



另外,你不应该对GC做任何事情。只是不要。



这并不意味着管理系统内存泄漏是不可能的。它们很有可能,但对它的理解需要更准确地考虑内存泄漏是什么;这不是微不足道的。在受管系统中,您可以防止意外内存泄漏,但您可以轻松创建非常真实的设计级内存泄漏。有关详细信息,请参阅我过去的答案:

Garbage collectotion负责所有内存管理 [ ^ ],

推迟循环中的变量会导致内存泄漏? [ ^ ],

最好的摆脱方法导致内存不足的公共静态列表 [ ^ ],

MDI表单中的内存管理 [ ^ ]。



-SA

Hello

I''m writing a (VS2008,.Net_framework 3.5 ,VB.net) application

When I close a form with a big memory usage , I check the Taskmanager
and found that it ( the form ) didn''t release all the memory that was allocated , I tried many approachs but I think that all of them wasn''t the proper one cause the problem still there , or maybe I didn''t catch the point the right way. [for example : GC.collect , Me=nothing , Me.dispose , GC.SuppressFinalize(Me) .. etc ; quoted from the web. ]

My question is : Is this a/the right free way (cause I don''t have profiler) to check the memory usage of application..

And how can I release all the memory allocated for a form


Thank you very much

解决方案

The estimate done using TaskManager is so unreliable that is should not be taken in consideration. What it shows is not a really allocated memory. If you terminate some process, even unmanaged, all memory is reclaimed, period.

Also, you should not really do anything with GC. Just don''t.

It does not mean that with manages systems memory leaks are impossible. They are quite possible, but understanding of it requires more accurate consideration of what a memory leak is; this is not as trivial. In managed system, you are protected from accidental memory leaks, but you can easily create quite real design-level memory leaks. For further detail, please see my past answers:
Garbage collectotion takes care of all the memory management[^],
deferring varirable inside the loop can cuase memory leak?[^],
Best way to get rid of a public static List Causing an Out of Memory[^],
Memory management in MDI forms[^].

—SA


这篇关于VB.net表单关闭和内存释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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