Finding a resource leak in the background thread...

  • Thread starter Thread starter Cartoper
  • Start date Start date
C

Cartoper

I am developing on VS2005 SP1. I have a batch process that is running
in the background that is increasing the handle count of the app and
never decrements it. Here is the code that starts the thread:

ThreadStart threadDelegate = new ThreadStart(ProcessFileList);
this.webUpdateThread = new Thread(threadDelegate);
this.webUpdateThread.Start();

The call to start increases the handle count by 4 and it never goes
down. This all happens in a class called WebUpdate which is the
container for the thread. The class does contain one AutoResetEvent
that is closed in WebUpdate.Dispose() method and two (2) events
handlers. When the thread is finished one of the event handlers is
called to tell the main thread to clean up the WebUpdate class. After
the clean up, which is both calling WebUpdate.Dispose() and setting it
to null, GC.Collect() is called and the handle count is still 4 higher
then when it all began.

I have checked the handle count right before the end of the thread and
it is 5 higher then when everything started, after WebUpdate.Dispose()
is called it is back to 4 higher.

What am I missing?

Cartoper
 
I am developing on VS2005 SP1.  I have a batch process that is running
in the background that is increasing the handle count of the app and
never decrements it. [...]

Why are you reposting this question, in a completely different newsgroup?  
This sort of multi-posting is a bad idea, especially since your question  
is already being addressed in the C# newsgroup.  Please don't do that.

Wll, because there are a TON of newsgroups out there and I know that
folks always read all of them. Maybe, just maybe there is a VB.Net or
C++/CLI programmer that knows the answer that reads this forum but not
the C# forum. It all sort of goes back to the concept of: Don't put
all your eggs in one basket.
 
Cartoper said:
I am developing on VS2005 SP1. I have a batch process that is running
in the background that is increasing the handle count of the app and
never decrements it. [...]
Why are you reposting this question, in a completely different newsgroup?
This sort of multi-posting is a bad idea, especially since your question
is already being addressed in the C# newsgroup. Please don't do that.

Wll, because there are a TON of newsgroups out there and I know that
folks always read all of them. Maybe, just maybe there is a VB.Net or
C++/CLI programmer that knows the answer that reads this forum but not
the C# forum. It all sort of goes back to the concept of: Don't put
all your eggs in one basket.

The problem is that a lot of us *do* read all of those newsgroups, or a
great deal of them at least. Having to post "I already answered this in ng
X" in X - 1 newsgroups to save the rest some time and join up discussions
gets old fast. This is a cooperative effort, here -- your "putting your eggs
in all baskets" strategy effectively means that your time is more valuable
than the rest of us. Not a good way to gain friends & influence people.

Don't post X messages in X newsgroups (multiposting). If you must address
more than one newsgroup, post one message to X newsgroups simultaneously and
set Followup-To (crossposting). I've heard it said that you can't do this
with Google, I have no idea if it's true, but it's hardly a good excuse in
any case -- use a real newsreader and one of the hundreds of free servers
out there.

If you truly have no clue which newsgroup could be appropriate, then *ask*.
People will be more than happy to direct you. Posting your question in one
newsgroup that turns out to be inappropriate is usually no disaster either.
Spamming as many newsgroups as possible will just antagonize people.

The "suppose what the world would look like if everybody did this" guideline
may be useful, here. We'd effectively just have one big, unreadable
newsgroup for everything.
 
Well, you're misusing the concept.  If I want to know whether it's better  
to use an acetylene torch or MIG welder to replace the muffler on my car,  
the fact is that there are lots of people reading all sorts of unrelated  
newsgroups (like the C# or .NET Framework newsgroups) who might actually  
know the answer to that question.  The best chance for me to get someone 
who knows the answer to the question is to post the question to every  
newsgroup I can find.

But that doesn't mean that's an acceptable use of the newsgroups.

The fact is, there are not "a TON of newsgroups" in which your question is 
relevant.  It's also not true that of the very small number of newsgroups  
where the question might be relevant, different people are reading those  
newsgroups.  So when you multipost, you just wind up making many of the  
same people read your question over and over.

Frankly, the question wasn't really on-topic in the C# newsgroup, but  
rather is more relevant here in the general-purpose Framework newsgroup.  
But in no case would a question that's on-topic in the C# newsgroup also  
be on-topic in the C++/CLI newsgroup or a VB.NET newsgroup.  If you think  
it is, that's a very good sign it's not on-topic in _any_ of those  
newsgroups and it would be much better for you to find the one newsgroup  
in which it is on-topic.

Inasmuch as the C# newsgroup winds up catching a lot of the Framework  
questions when posted in the context of a C# program, then if you're using 
C# it might make sense to include that newsgroup.  But even then, you  
should only include the post as a cross-post.  Posting as a multi-post, as  
you've done here, means that multiple people will be investing their time  
and energy trying to answer a question that may have already been answered 
elsewhere.

You're wasting people's time when you multi-post, and that's disrespectful..

Pete

This is ment to be rhetorical: If this is such a waste of your time,
why spend so much time replying?
 
Back
Top