清除Control在vb.net中的垃圾收集 [英] Clear Control's garbage collection in vb.net

查看:111
本文介绍了清除Control在vb.net中的垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生......



在我遇到问题的情况下,在一个表格中有两个按钮,我在不同的按钮点击事件上打开相同的表格,但我做不同的操作,假设在表单的文本框中我将数据插入table1,第二次这个表单打开时用第二个按钮单击事件比我将数据插入table2,现在问题是当我输入文本到文本框然后我用关闭按钮关闭标题栏然后我打开表单,第二个按钮点击事件表格上面有我输入的文字..



我也尝试me.textbox.dispose()表单关闭事件,

但在第二次文本框中是不可用的,因为文本框被处理掉了,..

所以如何解决..如何

Respected Sir...

In my case of problem there is two Button in one form ,and i open same form on different buttons click event but i do different operation, assume that in textbox of form i insert data to table1 and second time while this form open with second buttons click event than i insert data to table2,now problem is that while i input text to textbox then i close with close button of titlebar then i open form with second buttons click event the form having text which i entered last time ..

I also try me.textbox.dispose() in form closing event ,
but in secondtime textbox is nt available because text box is disposed,..
so how to solve..it

推荐答案

这个问题毫无意义。在.NET中,垃圾收集是自动的,由 GC 执行。你不需要做任何事情。请参阅:

http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science %29 [ ^ ]。< br $>


System.IDisposable System.IDisposable 是通常与GC无关。



但是,您不应该创建因错误设置而导致GC无法执行其工作的内存泄漏。您可以在我过去的答案中找到更多详细信息:

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

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

最好的摆脱方法导致内存不足的公共静态列表 [ ^ ], MDI表格中的内存管理 [ ^ ]。



参见: http://msdn.microsoft.com/en-us/library/system.idisposable.aspx [ ^ ]。



-SA
The question makes no sense. In .NET, garbage collection is automatic, performed by GC. You don''t need to do anything about it. Please see:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[^].

And System.IDisposable or System.IDisposable is generally unrelated to GC.

However, you should not create memory leaks which can appear by wrong desing preventing GC from doing its work. You can find further detail in 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[^].

See also: http://msdn.microsoft.com/en-us/library/system.idisposable.aspx[^].

—SA


这篇关于清除Control在vb.net中的垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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