473,401 Members | 2,125 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,401 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 6743
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 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.