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 / Distributed Applications / December 2003

Tip: Looking for answers? Try searching our database.

Async Socket:  Rising Thread Count

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morgan Leppink - 10 Dec 2003 20:54 GMT
Hi all -

We have been developing a complex TCP socket communication
app that is responsible for keeping numerous connections
open to clients on routable IPs.  The app receives request
on a non-routable listener socket that marshals
communications between the non-routable netowrk and the
clients out on the routable network.

The app runs as a .NET service in Win2K Server.  Async
sockets are being used, with BeginSend(), BeginReceive(),
EndSend(), EndReceive(), etc.  Please correct me if I'm
wrong, but our understanding is that these async events
execute on a thread provided by a thread pool created by
the OS.

Operationally, the app is doing exactly what it designed
to do, BUT, the total thread count for the application
gradually rises over time (as displayed by Task Manager).  
It starts out at about 18 threads, but after 24 hours it's
up to over 60 threads, and it keeps rising from there.

As expected with an async app, the number of threads does
not have a direct relationship to the number of open
connections.   However, it is the marshalling of numerous
TCP messages that seems to make the thread count rise.  
The marshalling of messages is when those asynch events
fire, and so I assume that the OS is creating additional
threads from the pool when they are not neccesary for the
operation of the app.

I ALSO assume that we have a bug somewhere.  What I am
looking for are likely causes of the OS continuing to
assign additional threads from the pool to my process -
for example, what types of cleanup failures would cause
this?  What if EndSend() did not get called properly?  The
app is huge, so I would like to narrow it down to the most
likely culprit(s) so we can track this down.

Any other sage advice regarding this type of app would
also be appreciated.

Thanks in advance,

Morgan Leppink
.
Feroze [MSFT] - 26 Dec 2003 21:32 GMT
In order to pinpoint what is happening, you will need to debug this
application. The best way is to attach a debugger of choice to the service,
and break in from time to time to see what the threads are doing. Are they
managed threads executing code in your application ? If so, that might give
you an idea of what code in your application is responsible.

On the other hand, if the Taskmanager is showing a lot of threads, but the
debugger does not show any managed code executing on them, it might be CLR
threads. Then you will have to do some native debugging (using windbg for
example) and see what each of those threads are doing.

Also, do you create threads explicitly, either through ThreadPoo.*
functions, or creating a new Thread object in CLR ?

Signature

Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

> Hi all -
>
[quoted text clipped - 42 lines]
> Morgan Leppink
> .

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.