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 / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Thread memory consumption

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian Stoop - 26 Mar 2008 20:35 GMT
My .NET 1.1 program allocates many Threads that loop making database calls
and other stuff.

Thread1 = new Thread(new ThreadStart(this.Thread1));
Thread1.Start();

Thread2 = new Thread(new ThreadStart(this.Thread2));
Thread2.Start();

while(true){
   Thread.Sleep(1000);
}

How can I tell how much memory each Thread is consuming, and distinguish
which one is taking the most ?.

(I would like to create memory counters for perfmon)

thanks B.
Jon Skeet [C# MVP] - 26 Mar 2008 20:51 GMT
> My .NET 1.1 program allocates many Threads that loop making database calls
> and other stuff.
[quoted text clipped - 13 lines]
>
> (I would like to create memory counters for perfmon)

There's no real idea of the amount of memory a thread takes, beyond
what's on the stack. As far as .NET is concerned, the objects you're
creating on each thread are available to *all* threads, because they
all share the same heap.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Jeroen Mostert - 26 Mar 2008 20:57 GMT
> My .NET 1.1 program allocates many Threads that loop making database calls
> and other stuff.
[quoted text clipped - 11 lines]
> How can I tell how much memory each Thread is consuming, and distinguish
> which one is taking the most ?.

Threads do not consume memory (aside from their stack, which is
constant-sized); processes consume memory. The whole point of threads is
that they share process state.

If your threads do have a sense of "ownership" of objects and you want to
keep track of which thread is allocating the most of these objects, you'll
have to keep track of that yourself when you create them.

Signature

J.

Willy Denoyette [MVP] - 26 Mar 2008 22:49 GMT
>> My .NET 1.1 program allocates many Threads that loop making database
>> calls and other stuff.
[quoted text clipped - 15 lines]
> constant-sized); processes consume memory. The whole point of threads is
> that they share process state.

Agreed, but keep in mind that CLR threads have their stack space set to
(comitted by the CLR) 1MB (4MB for 64 bit code threads) per default.
Creating a few hundred threads may bite you real hard ;-).

Willy.

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.