473,799 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory Leaks?

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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!
Nov 20 '05 #1
17 1463
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******** ******@TK2MSFTN GP09.phx.gbl...
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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!

Nov 20 '05 #2
"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

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

Nov 20 '05 #3
Then why is the memory not completely reclaimed?

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"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

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

Nov 20 '05 #4
On top of that, Microsoft Task Manager doesn't really deal well with a
managed environment, in fact, it kinda sucks in general. When .NET releases
memory Task manager doesn't really catch it sometimes, or whats reported as
being released and really is sometimes varies.

With those other links given to you you will also see tht GC invokes about
once every 47 seconds... How this number came to be, I don't know, but
almost every GC test I see always results to about that number.

cooky..

You can always get your memory usage by using

GC.GetTotalMemo ry(False)

I use .NET Memory Profiler by scitech, great tool...

"David Schwartz" <da**@hr-symphony.com> wrote in message
news:ez******** ******@TK2MSFTN GP09.phx.gbl...
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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!

Nov 20 '05 #5
"David Schwartz" <da**@hr-symphony.com> schrieb
Then why is the memory not completely reclaimed?


Did you read the article?
--
Armin

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

Nov 20 '05 #6
Yes, I read the article, and basically it says that .NET handles all memory
management for me. The problem is that my little test program proves
otherwise - memory is not reclaimed when I close a form.

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"David Schwartz" <da**@hr-symphony.com> schrieb
Then why is the memory not completely reclaimed?


Did you read the article?
--
Armin

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

Nov 20 '05 #7
Did you read my comments? basically, task manager is a P.O.S.
"David Schwartz" <da**@hr-symphony.com> wrote in message
news:ex******** ******@TK2MSFTN GP11.phx.gbl...
Yes, I read the article, and basically it says that .NET handles all memory management for me. The problem is that my little test program proves
otherwise - memory is not reclaimed when I close a form.

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"David Schwartz" <da**@hr-symphony.com> schrieb
Then why is the memory not completely reclaimed?


Did you read the article?
--
Armin

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


Nov 20 '05 #8
* "David Schwartz" <da**@hr-symphony.com> scripsit:
Yes, I read the article, and basically it says that .NET handles all memory
management for me. The problem is that my little test program proves
otherwise - memory is not reclaimed when I close a form.


That's by design. The GC will release the memory if the system needs
memory. Don't worry about that!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9
I see the same results by using System.GC.GetTo talMemory... Memory is not
completely reclaimed.
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Did you read my comments? basically, task manager is a P.O.S.
"David Schwartz" <da**@hr-symphony.com> wrote in message
news:ex******** ******@TK2MSFTN GP11.phx.gbl...
Yes, I read the article, and basically it says that .NET handles all

memory
management for me. The problem is that my little test program proves
otherwise - memory is not reclaimed when I close a form.

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"David Schwartz" <da**@hr-symphony.com> schrieb
> Then why is the memory not completely reclaimed?

Did you read the article?
--
Armin

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



Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
16694
by: Maurice | last post by:
Hi there, I'm experiencing big memory problems on my webserver. First on an old RedHat 7.2 system, now on an other fresh installed Suse 8.2 system: Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3 20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003 Apache 1.3.27-41 PHP 4.3.1-52 MySQL 3.23.55-20
0
1873
by: Steve Binney | last post by:
My code makes synchronous HttpWebRequest and HttpRebResponse calls. In VS 2003, I am getting memory leaks and event handle leaks. I am closing all streams and using "using"statements. I have used .Net memory profiler from Sci Tech to analyze the leaks and they are coming from inside HttpWebRequest and HttpRebResponse. When I run my code on VS2005, I do not get any leaks. Is this problem fixed in .Net 1.1 SP1? I may not be able to wait...
4
2354
by: Morten Aune Lyrstad | last post by:
Ok, now I'm officially confused. I have a large project going, which uses a win32 ui library I am developing myself. And I'm getting weird memory leaks. I don't know if I can explain what is going on, but I really need some help on this one. Ok, so I have this class defined (written by Randy Charles Morin, www.kbcafe.com) which detects memory leaks. It creates a memory check point in the constructor, and another in the destructor, and...
2
4959
by: Generic Usenet Account | last post by:
I have been using STL for a long time now, without any problems. Recently we generated a purification report on our software using Rational Purify, and we found some memory leaks. My colleague claims that some of the memory leaks are due to the fact that "STL is wrought with memory leaks". Of course I disagree. I think that there are no "inherent leaks" with STL, but if used improperly, leaks will occur. One common source of leak that...
8
3414
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
0
3908
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from dllmodul.cpp(102) similar to what is mentioned below)... I am calling MFC as part of unmanaged code used by the managed code. +--------
4
5729
by: ali.jan | last post by:
Hi, It is trivial to load an assembly in a new Application Domain. Is there any way of loading an assembly in a new process? I tried using the Process class like this: Process p = new Process() p.StartInfo.FileName = mStartupFile p.StartInfo.UseShellExecute = False
23
4575
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
3
5328
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
16
5106
by: graham.keellings | last post by:
hi, I'm looking for an open source memory pool. It's for use on an embedded system, if that makes any difference. Something with garbage collection/defragmentation would be nice. It should have the ability to allocate different size chunks of memory not just a single size. It should error check for double free, etc. And it should be usable by a mixture of C and C++ subsystems. If I get that, I'm happy. Thank you very much.
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.