How: multiple program instances sharing same data

  • Thread starter Thread starter Zytan
  • Start date Start date
Zytan said:
This page http://www.thescripts.com/forum/thread229335.html says

"The stack is set to an arbitrarily small value when the program is
first loaded. The stack then grows on demand to meet the needs of the
thread. This is implemented by placing a page with PAGE_GUARD access
at the end of the current stack. When your code causes the stack
pointer to point to an address on this page, an exception occurs. The
system will commit your desired page. The 1M was the default maximum
stack size that can be commit."

So, it looks like it wouldn't make any difference, anyway.

Zytan


This article is based on the V1.X Framework and not quite correct.
In V2, you can create threads with other stack sizes than the 1MB default,
but the threads created before your program runs will still be 1MB max. Of
course you can edit the PE file header and set all stacks to a lower value
for the whole process, but that's in general a bad idea, CLR application
are quite stack "hungry".
Note that stack space is always pre-committed for CLR threads, this is *not*
the case for unmanaged threads which is what the above describes.


Willy.
 
This article is based on the V1.X Framework and not quite correct.

Ok, good catch.
In V2, you can create threads with other stack sizes than the 1MB default,
but the threads created before your program runs will still be 1MB max.

My program makes a few threads, and they shouldn't need 1 MB each, so
I should reduce their sizes.
Of course you can edit the PE file header and set all stacks to a lower value
for the whole process, but that's in general a bad idea, CLR application
are quite stack "hungry".

Ok, so any thread stacks that I can't easily change (without hacking
the .exe) are better off left as-is... good enough.
Note that stack space is always pre-committed for CLR threads, this is *not*
the case for unmanaged threads which is what the above describes.

Oh, wait, so for CLR threads that start implicitly, their stack memory
are commited. Fine. But, for threads that *I* make, with Thread(),
their stack space is NOT commited? That means I don't need to worry
that they are 1 MB each, since that memory won't actually be committed
unless they really use it, right?

Thanks very much as always, Willy

Zytan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top