473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

handle leak

I have a vb.net program that leaks handles as reported by task manager.
After running for a couple of hours, task manager reports over 1000 handles,
and it continues to grow. I think I am failing to close or dispose
something. I've looked at the code and can't spot the problem. The program
is fairly big (10k lines). I can ask it to do something that always
increases the handle count, so the problem is reproducible.

What I don't know is how to go about finding what is wrong. For example,
I'd like to know what kind of handles task manager is talking about. Are
they file handles, fonts, or what? I'd like to snapshot the handles, take an
action that raises the handle count, and then find out what kind of handles
were produced and still exist.

Can I do this kind of thing in the IDE? Do I need a tool? FYI, I'm using
..net 2003 v7.1 and fw 1.1, sp1.

Jul 5 '07 #1
1 6736
After some trial and error, I find that the leak is associated with starting
threads. The threads are background threads not in the threadpool. The
threads are started with Threading.Thread.Start, and they run to completion.
As time passes, Task Manager reports steadily rising Handles. If I replace
the .Start call with a direct call to the same method (ie continue
functioning as before but entirely on one thread), then the handle leak goes
away. On a keystroke, the app will garbage collect, so I can see what task
manager is reporting with or without coerced garbage collection.

In summary, if MyThread will call sub Abcde() when started, then
MyThread.start leaks handles. If I replace MyThread.start with a direct call
to Abcde(), then there is no leak of handles.

I searched the internet, and I found others complaining about the same
problem. I found no solutions. What is going on?
"AMercer" wrote:
I have a vb.net program that leaks handles as reported by task manager.
After running for a couple of hours, task manager reports over 1000 handles,
and it continues to grow. I think I am failing to close or dispose
something. I've looked at the code and can't spot the problem. The program
is fairly big (10k lines). I can ask it to do something that always
increases the handle count, so the problem is reproducible.

What I don't know is how to go about finding what is wrong. For example,
I'd like to know what kind of handles task manager is talking about. Are
they file handles, fonts, or what? I'd like to snapshot the handles, take an
action that raises the handle count, and then find out what kind of handles
were produced and still exist.

Can I do this kind of thing in the IDE? Do I need a tool? FYI, I'm using
.net 2003 v7.1 and fw 1.1, sp1.
Jul 5 '07 #2

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

Similar topics

0
by: Yair | last post by:
Hello, I've encounter a leak of 50 handles, when trying to query performance counters through the registry using HKEY_PERFORMANCE_DATA registry key. I've found out that when netfxperf.dll is...
12
by: Ken Brubaker | last post by:
I am using DB2 8.5 FP5 on Windows 2000 Server and have noticed what appears to be a handle leak. When I execute a DB2 connect statement in a command window, followed by a DB2 connect reset...
2
by: Bryan Mayland | last post by:
I've got a problem with a System.Net.Socket that is failing on connect. Each time I attempt a connection, 3 handles are allocated, and when the connect fails 2 handles are freed. If left retrying...
10
by: Manfred Braun | last post by:
Hi All, I am writing a proggi, which should monitor some processes. While doing this, I needed a test-program and wrote one, which does nothing else than to consume some cpu, sometimes more,...
3
by: Jayme Pechan | last post by:
I was wondering if someone could help me understand why it seems that creating threads using the code below causes handles to seemingly leak. System.Threading.Thread threadRunAsync = new...
4
by: NickP | last post by:
Hi there, This is really crazy! 1. Make a folder 2. Put a text file in the folder 3. Run the following code... Dim pop As New OpenFileDialog Using pop
1
by: Pranil Kanderi | last post by:
I have a huge application with lots of custom controls. The app had a memory leak but fixed that by calling the dispose method where needed and now the user objects are very stable, when I am...
0
by: PlayQ | last post by:
Hello, I am using the C# example code in the WMEncoder Series 9 SDK to encode a series of audio files but after a while I notice a handle leak in the system. The handle count keeps going up until...
1
by: not_a_commie | last post by:
My C# app (using managed DirectInput) leaks handles like mad on one of my test boxes. (The other test boxes are fine.) The handle being leaked (as reported by the SysInternals Handle program) is ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.