Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Finding a resource leak in the background thread...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cartoper - 19 Mar 2008 01:29 GMT
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
Peter Duniho - 19 Mar 2008 02:00 GMT
> 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.
Cartoper - 19 Mar 2008 13:18 GMT
On Mar 18, 9:00 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > 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
[quoted text clipped - 3 lines]
> 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.
Peter Duniho - 19 Mar 2008 19:55 GMT
> 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.

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
Cartoper - 20 Mar 2008 00:33 GMT
On Mar 19, 2:55 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > 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
[quoted text clipped - 37 lines]
>
> Pete

This is ment to be rhetorical:  If this is such a waste of your time,
why spend so much time replying?
Peter Duniho - 20 Mar 2008 02:27 GMT
> [...]
> This is ment to be rhetorical:  If this is such a waste of your time,
> why spend so much time replying?

The waste of my time is you multi-posting.

It may also be a waste of my time to try to educate you, but I remain  
hopeful that you could learn something.  If not, so be it...at least it is  
my choice to waste my time that way, not yours.

Pete
Jeroen Mostert - 19 Mar 2008 20:01 GMT
> On Mar 18, 9:00 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
> wrote:
[quoted text clipped - 10 lines]
> 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.

Signature

J.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.