Thread Limits

  • Thread starter Thread starter Yves Gazin
  • Start date Start date
Y

Yves Gazin

Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves
 
You normally get about 800 to 900 threads on a 1GB machine, each thread
takes up 2MB memory for the stack.

I would code something that would do like this in C# for threads (or any
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----
 
Don't listen to McNutt - it's bullshit. According to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
(Remarks)

each process can create a maximum of 2028 threads, so WinNT/Win2k can have
FAR more than 800 threads. And we're also talking about the virtual address
space and not the physical memory.

Also, the default stack size is 1Mb and not 2Mb. This can be
reduced/increased by the developer anyway.

How many threads is the application using? AFAIK the biggest disadvantage of
threads are context switches - every time a different thread runs the OS has
to perform a context switch - something considered to be "expensive" in
terms of resource usage. However if the threads are idle most of the time
then this is usually not a problem.


-Flo-

Duncan McNutt said:
You normally get about 800 to 900 threads on a 1GB machine, each thread
takes up 2MB memory for the stack.

I would code something that would do like this in C# for threads (or any
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Yves Gazin said:
Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves
 
Really , I get OutOfMemory Exceptions on a single process with 800 to 900
threads on my 1GB ram machine.

Ive ****in tested it here so Ive seen that limit on my thread count.

Talkin bullshit my ass, go code it and find out.

ITS FUCING DEPENDANT ON MEMORY so what if a process can create 2048 threads,
IN THEORY YES, on a 1GB ram machine I got 800 to 900 MAX. ****TARD:
--

Duncan McNutt
Microsoft Product Deactivation Team
--


Florian said:
Don't listen to McNutt - it's bullshit. According to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/createthread.asp
(Remarks)

each process can create a maximum of 2028 threads, so WinNT/Win2k can have
FAR more than 800 threads. And we're also talking about the virtual address
space and not the physical memory.

Also, the default stack size is 1Mb and not 2Mb. This can be
reduced/increased by the developer anyway.

How many threads is the application using? AFAIK the biggest disadvantage of
threads are context switches - every time a different thread runs the OS has
to perform a context switch - something considered to be "expensive" in
terms of resource usage. However if the threads are idle most of the time
then this is usually not a problem.


-Flo-

Duncan McNutt said:
You normally get about 800 to 900 threads on a 1GB machine, each thread
takes up 2MB memory for the stack.

I would code something that would do like this in C# for threads (or any
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Yves Gazin said:
Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves

 
E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1151

E:\ThreadLimitTest\bin\Release>


1151, other processes I got 800 to 900 with other memory usage.

NOT 2048 on my 1GB ram, its memory dependant also. ****wit.

--

Run the freakin code or roll yer own..

--

using System;
using System.Threading;
using System.Text;

namespace ThreadLimitTest
{
class ClassThreadLimitTest
{
static int threadCount = 0;
static bool maxReached = false;
[STAThread]
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(threadFn);

try
{
while (maxReached == false)
{
Thread t = new Thread(ts);
t.Start();
}
}

catch (OutOfMemoryException e)
{
Console.WriteLine(@"INFO: OutOfMemoryException caught... {0}",
e.Message);
maxReached = true;
}

finally
{
Console.WriteLine(@"Threads created = {0}", threadCount);
}
}

private static void threadFn()
{
while (true)
{
threadCount++;
Thread.Sleep(1000);
}
}
}
}


--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Rename you'reself to BLO from flo, asshat

--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Really , I get OutOfMemory Exceptions on a single process with 800 to 900
threads on my 1GB ram machine.

Ive ****in tested it here so Ive seen that limit on my thread count.

Talkin bullshit my ass, go code it and find out.

ITS FUCING DEPENDANT ON MEMORY so what if a process can create 2048 threads,
IN THEORY YES, on a 1GB ram machine I got 800 to 900 MAX. ****TARD:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
disadvantage OS
has
a
ny
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves


 
// Fixed a bug in the thread count, stil similar result.

//approximately 1000 threads average on a 1GB ram machine with 1.5 GB
virtual memory.

using System;
using System.Threading;
using System.Text;

namespace ThreadLimitTest
{
class ClassThreadLimitTest
{
static int threadCount = 0;
static bool maxReached = false;
[STAThread]
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(threadFn);

try
{
while (maxReached == false)
{
Thread t = new Thread(ts);
t.Start();
}
}

catch (OutOfMemoryException e)
{
Console.WriteLine(@"INFO: OutOfMemoryException caught... {0}",
e.Message);
maxReached = true;
}

finally
{
Console.WriteLine(@"Threads created = {0}", threadCount);
Console.WriteLine(@"Press ENTER to exit.");
Console.ReadLine();
}
}

private static void threadFn()
{
bool setVar = false;
while (true)
{
if (setVar == false)
{
setVar = true;
threadCount++;
}
Thread.Sleep(1000);
}
}
}
}


--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1151

E:\ThreadLimitTest\bin\Release>


1151, other processes I got 800 to 900 with other memory usage.

NOT 2048 on my 1GB ram, its memory dependant also. ****wit.

--

Run the freakin code or roll yer own..

--

using System;
using System.Threading;
using System.Text;

namespace ThreadLimitTest
{
class ClassThreadLimitTest
{
static int threadCount = 0;
static bool maxReached = false;
[STAThread]
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(threadFn);

try
{
while (maxReached == false)
{
Thread t = new Thread(ts);
t.Start();
}
}

catch (OutOfMemoryException e)
{
Console.WriteLine(@"INFO: OutOfMemoryException caught... {0}",
e.Message);
maxReached = true;
}

finally
{
Console.WriteLine(@"Threads created = {0}", threadCount);
}
}

private static void threadFn()
{
while (true)
{
threadCount++;
Thread.Sleep(1000);
}
}
}
}


--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Rename you'reself to BLO from flo, asshat
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
the
(or
a
ny
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves


 
Where is you're magical 2048 threads per process??



E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1257
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1258
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1260
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1266
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1255
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>




--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1151

E:\ThreadLimitTest\bin\Release>


1151, other processes I got 800 to 900 with other memory usage.

NOT 2048 on my 1GB ram, its memory dependant also. ****wit.

--

Run the freakin code or roll yer own..

--

using System;
using System.Threading;
using System.Text;

namespace ThreadLimitTest
{
class ClassThreadLimitTest
{
static int threadCount = 0;
static bool maxReached = false;
[STAThread]
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(threadFn);

try
{
while (maxReached == false)
{
Thread t = new Thread(ts);
t.Start();
}
}

catch (OutOfMemoryException e)
{
Console.WriteLine(@"INFO: OutOfMemoryException caught... {0}",
e.Message);
maxReached = true;
}

finally
{
Console.WriteLine(@"Threads created = {0}", threadCount);
}
}

private static void threadFn()
{
while (true)
{
threadCount++;
Thread.Sleep(1000);
}
}
}
}


--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Rename you'reself to BLO from flo, asshat
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
the
(or
a
ny
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves


 
Well? Where is my 2048 threads per process?



--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Where is you're magical 2048 threads per process??



E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1257
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1258
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1260
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1266
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1255
Press ENTER to exit.


E:\ThreadLimitTest\bin\Release>




--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
E:\ThreadLimitTest\bin\Release>ThreadLimitTest.exe
INFO: OutOfMemoryException caught... Exception of type
System.OutOfMemoryException was thrown.
Threads created = 1151

E:\ThreadLimitTest\bin\Release>


1151, other processes I got 800 to 900 with other memory usage.

NOT 2048 on my 1GB ram, its memory dependant also. ****wit.

--

Run the freakin code or roll yer own..

--

using System;
using System.Threading;
using System.Text;

namespace ThreadLimitTest
{
class ClassThreadLimitTest
{
static int threadCount = 0;
static bool maxReached = false;
[STAThread]
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(threadFn);

try
{
while (maxReached == false)
{
Thread t = new Thread(ts);
t.Start();
}
}

catch (OutOfMemoryException e)
{
Console.WriteLine(@"INFO: OutOfMemoryException caught... {0}",
e.Message);
maxReached = true;
}

finally
{
Console.WriteLine(@"Threads created = {0}", threadCount);
}
}

private static void threadFn()
{
while (true)
{
threadCount++;
Thread.Sleep(1000);
}
}
}
}


--

Duncan McNutt
Microsoft Product Deactivation Team
--


Duncan McNutt said:
Rename you'reself to BLO from flo, asshat
to
900
threads on my 1GB ram machine.

Ive ****in tested it here so Ive seen that limit on my thread count.

Talkin bullshit my ass, go code it and find out.

ITS FUCING DEPENDANT ON MEMORY so what if a process can create 2048
threads,
IN THEORY YES, on a 1GB ram machine I got 800 to 900 MAX. ****TARD:
--

Duncan McNutt
Microsoft Product Deactivation Team
--


Don't listen to McNutt - it's bullshit. According to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/createthread.asp
(Remarks)

each process can create a maximum of 2028 threads, so WinNT/Win2k can
have
FAR more than 800 threads. And we're also talking about the virtual
address
space and not the physical memory.

Also, the default stack size is 1Mb and not 2Mb. This can be
reduced/increased by the developer anyway.

How many threads is the application using? AFAIK the biggest
disadvantage
of
threads are context switches - every time a different thread runs
the
OS
has
to perform a context switch - something considered to be
"expensive"
in
terms of resource usage. However if the threads are idle most of the
time
then this is usually not a problem.


-Flo-

You normally get about 800 to 900 threads on a 1GB machine, each
thread
takes up 2MB memory for the stack.

I would code something that would do like this in C# for threads
(or
a
ny
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current
memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves


 
Facts speak for themselves regardless.

Proof is in that code.

--

Duncan McNutt
Microsoft Product Deactivation Team
--


Paul Dietrich said:
Duncan,
No one will listen to you if you make a habit out of insult and angry
replies. Most people mentally subtract 15 IQ points every time they see a
post like the whole series that you've done. The language detracts what
might have OTHERWISE been an intelligent, and reasonable response.

You really need to cool dawn before posting, or not let anger show. It will
really help with your standing.




Really , I get OutOfMemory Exceptions on a single process with 800 to 900
threads on my 1GB ram machine.

Ive ****in tested it here so Ive seen that limit on my thread count.

Talkin bullshit my ass, go code it and find out.

ITS FUCING DEPENDANT ON MEMORY so what if a process can create 2048
threads,
IN THEORY YES, on a 1GB ram machine I got 800 to 900 MAX. ****TARD:
--

Duncan McNutt
Microsoft Product Deactivation Team
--


Florian said:
Don't listen to McNutt - it's bullshit. According to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dllproc/bas
e/createthread.asp
(Remarks)

each process can create a maximum of 2028 threads, so WinNT/Win2k can
have
FAR more than 800 threads. And we're also talking about the virtual address
space and not the physical memory.

Also, the default stack size is 1Mb and not 2Mb. This can be
reduced/increased by the developer anyway.

How many threads is the application using? AFAIK the biggest
disadvantage of
threads are context switches - every time a different thread runs the
OS
has
to perform a context switch - something considered to be "expensive" in
terms of resource usage. However if the threads are idle most of the
time
then this is usually not a problem.


-Flo-

You normally get about 800 to 900 threads on a 1GB machine, each
thread
takes up 2MB memory for the stack.

I would code something that would do like this in C# for threads (or
any
language)

To max out threads on a system code something like the following...

//----------
private static void preLoadThreads()
{
ThreadStart ts = new ThreadStart(someThreadCallback);

try
{
while (true)
{ // exit on OutOfMemory exception
ta = new Thread(ts);
ta.Start();
}
}

catch (OutOfMemoryException)
{
Console.WriteLine(@"INFO: Max threads reached for current
memory
{0}", ta.Length);
}

finally
{
allThreadsReady = true; // signal threads to start
}
}
//-----
private static void someThreadCallback()
{
while (true)
{
if (allThreadsReady == true)
{
callSomeMethodHere(blah, blah);
}
Thread.Sleep(100);
}
}

//-----




--
Duncan McNutt
Microsoft Product Deactivation Team
--


Please let me know if this is the right user group or
not. If not, please inform me on the one to use.

Question: is there a rule with regard to using threads in
an executable (number, priority, cycle time...)?

I would like to evaluate an existing application running a
multitude of threads ot different priorities and cycle
times to insure it's not working at the edge of the OS
capabilities.

Yves


 
Facts speak for themselves regardless.
Wrong. As every good politician knows, when dealing with people, facts are
only secondary, even tertiary, compared to delivery. If you cannot get
past part 1 (the delivery), no one will listen to part 2 (the facts). NOR,
will anyone even read a post with your name on it in the future if they see
a pattern of abusive language in your previous posts.

This said, your case in not yot irredemable. Apologise for the language
(not the facts), and don't behave like that again. People will forgive you,
mostly. Eventually, they may even start to respect you, and your advise.

This I had to learn the hard way, too. That is all.

Paul Dietrich
 
I aint a politician nor do i care for politics

I can always change name :D

I dont care what ppl think they can bite me
 
Back
Top