内存泄漏? [英] Memory Leaks?

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

问题描述

有没有人注意到他们的VB.NET Windows窗体应用程序中存在内存泄漏?我的应用程序

肯定有一些内存泄漏,所以我做了一个简单的测试,看看它是我的

应用程序还是关于VB.NET的东西。


我创建了一个包含2个表单的测试应用程序。 Form1有一个命令按钮,其代码为



Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

系统。 EventArgs)处理Button1.Click

Dim x As New Form2

x.Show()

End Sub


观察内存使用情况,我看到当我点击按钮显示Form2时,使用的内存在10-20K之间上涨

。当我关闭Form2时,内存是

没有回收。


关闭表单时我需要做些什么才能回收内存?


谢谢!

Has anyone noticed memory leaks in their VB.NET Windows Forms apps? My app
definitely has some memory leaks, so I did a simple test to see if it was my
app or something about VB.NET.

I created a test app with 2 forms. Form1 has a command button with the
following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim x As New Form2
x.Show()
End Sub

Watching the memory usage, I see that the used memory goes up between 10-20K
when I click the button to show Form2. When I close Form2, the memory is
not reclaimed.

Is there something I need to do to reclaim memory when closing a form?

Thanks!

推荐答案

Form.Dispose


然后需要一些GC清理前的时间


问候

Fredrik Melin

" David Schwartz" <哒** @ hr-symphony.com>在消息中写道

新闻:ez ************** @ TK2MSFTNGP09.phx.gbl ...
Form.Dispose

Then it takes some time before GC cleans up

Regards
Fredrik Melin
"David Schwartz" <da**@hr-symphony.com> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...
有没有人注意到内存泄漏在他们的VB.NET Windows窗体应用程序?我的
应用程序肯定有一些内存泄漏,所以我做了一个简单的测试,看看它是我的应用程序或VB.NET的东西。

我创建了一个测试应用程序与2个表格。 Form1有一个带有
以下代码的命令按钮:
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click
Dim x作为New Form2
x.Show()
End Sub

观察内存使用情况,我看到当我点击时使用的内存在
10-20K之间上升显示Form2的按钮。当我关闭Form2时,内存无法回收。

关闭表单时是否需要回收内存?

谢谢!
Has anyone noticed memory leaks in their VB.NET Windows Forms apps? My app definitely has some memory leaks, so I did a simple test to see if it was my app or something about VB.NET.

I created a test app with 2 forms. Form1 has a command button with the
following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim x As New Form2
x.Show()
End Sub

Watching the memory usage, I see that the used memory goes up between 10-20K when I click the button to show Form2. When I close Form2, the memory is
not reclaimed.

Is there something I need to do to reclaim memory when closing a form?

Thanks!



" David Schwartz" <哒** @ hr-symphony.com> schrieb
"David Schwartz" <da**@hr-symphony.com> schrieb

关闭
表单时,我需要做些什么才能回收内存?

Is there something I need to do to reclaim memory when closing a
form?




No.

http: //msdn.microsoft.com/library/en...management.asp

-

Armin


如何报价以及原因:
http:// www。 plig.net/nnq/nquote.html
http ://www.netmeister.org/news/learn2quote.html



No.

http://msdn.microsoft.com/library/en...management.asp
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


那么为什么内存没有完全回收?


" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

news:40 *********************** @ news.freenet.de ...
Then why is the memory not completely reclaimed?

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
David Schwartz <哒** @ hr-symphony.com> schrieb
"David Schwartz" <da**@hr-symphony.com> schrieb

关闭
表单时,我需要做些什么才能回收内存?


Is there something I need to do to reclaim memory when closing a
form?
No.


http://msdn.microsoft.com/ library / en ... management.asp

Armin

如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



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

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