473,414 Members | 1,667 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,414 software developers and data experts.

How many threads possible?

Each .net app, by default, has 25 threads (per processor) in the
threadpool, right? ... but when calling ThreadStart, I'm creating a
new thread and not using the threadpool, right?

I don't want to get into any lengthy discussion about the
best-practices and the best use of threads etc... I'm asking this
question just to satisfy my own curiosity:

On a typical windows server computer (Win2000 server or Win2003
server), how many threads can one create (using ThreadStart) before
running out of threads? What does it depend on? The number of
processors? Amt of RAM? The operating system? Machine.config
variables?

What's a ballpark figure on how many threads would be a typical upper
limit? Is the number in the hundreds or thousands or tens of
thousands?

Any feedback would be appreciated.

Thanks.

Nov 28 '06 #1
3 2483
If I remember I saw once an article saying this is mostly memory bound (that
is there is no hardcoded limit, it is just limited by the resource that is
exhausted first that is likely memory). You could also just give this a try
on your own machine to establish a lower limit.

As you noted this is anyway a theorical limit...

--
Patrice

"GroupReader" <ne***********@hotmail.coma écrit dans le message de news:
11**********************@h54g2000cwb.googlegroups. com...
Each .net app, by default, has 25 threads (per processor) in the
threadpool, right? ... but when calling ThreadStart, I'm creating a
new thread and not using the threadpool, right?

I don't want to get into any lengthy discussion about the
best-practices and the best use of threads etc... I'm asking this
question just to satisfy my own curiosity:

On a typical windows server computer (Win2000 server or Win2003
server), how many threads can one create (using ThreadStart) before
running out of threads? What does it depend on? The number of
processors? Amt of RAM? The operating system? Machine.config
variables?

What's a ballpark figure on how many threads would be a typical upper
limit? Is the number in the hundreds or thousands or tens of
thousands?

Any feedback would be appreciated.

Thanks.

Nov 28 '06 #2
By default, each OS thread gets 1 Meg of address space for its stack.
For normal windows, any process is limited to 2 Gig of address space for the
program. Thus, the ultimate limit is 2048 threads if your code takes no
space (highly unlikely).
Bob

"GroupReader" <ne***********@hotmail.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
Each .net app, by default, has 25 threads (per processor) in the
threadpool, right? ... but when calling ThreadStart, I'm creating a
new thread and not using the threadpool, right?

I don't want to get into any lengthy discussion about the
best-practices and the best use of threads etc... I'm asking this
question just to satisfy my own curiosity:

On a typical windows server computer (Win2000 server or Win2003
server), how many threads can one create (using ThreadStart) before
running out of threads? What does it depend on? The number of
processors? Amt of RAM? The operating system? Machine.config
variables?

What's a ballpark figure on how many threads would be a typical upper
limit? Is the number in the hundreds or thousands or tens of
thousands?

Any feedback would be appreciated.

Thanks.

Nov 28 '06 #3
Thanks for the quick answers!

I also ran a quick test as suggested which seems to support the 2048
limit. I created a loop that spawns new threads and got an "out of
memory exception" at just above 1800 threads.

For the record if anyone cares, my test was run on WinXP Pro, with 1GB
RAM total (about 250MB free), and only about 1.5GB of free disk space.

Thanks again.

Nov 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Przemysław Różycki | last post by:
Hello, I have written some code, which creates many threads for each connection ('main connection'). The purpose of this code is to balance the load between several connections ('pipes'). The...
3
by: Andreas Müller | last post by:
i need two loops that run forever. one of it receives data and stores it to a vector. the other one writes the elements of the vector to the disk. this means the vector is a receiver buffer. How...
5
by: Sunny | last post by:
Hi, I have to implement client/server application. The client have to instaniate an remoting object via http and pass some auth info. If the auth is OK, the client should invoke a method (or...
34
by: Kovan Akrei | last post by:
Hi, I would like to know how to reuse an object of a thread (if it is possible) in Csharp? I have the following program: using System; using System.Threading; using System.Collections; ...
3
by: Santosh | last post by:
Hi, I have a requirement while using ThreadPool class. I am creating n number of threads using ThreadPool class, using WaitCallback method. In this Method I want to stop all the threads started...
9
by: Arafangion | last post by:
Hello, recently I've been trying to figure out how the heck to just destroy a thread. I have since rewritten the code in question, but what I was trying to do was to use the .Abort() method, but...
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
4
by: MSDousti | last post by:
Hi I have written a VB .NET app, which uses several threads. I thought that when the user closes the main window (when MainForm.closed event occures, and I call application.exit) all running...
2
by: Alex | last post by:
Dear colleagues I am programming an application which starts a lot of threads for some calculations. The problem that I have is that when I start up to 100 threads then everything works fine....
7
by: Michael | last post by:
I'm writing an application that decodes a file containing binary records. Each record is a particular event type. Each record is translated into ASCII and then written to a file. Each file contains...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.