Hi,

I've a question / doubt about the option to set the stack size of a
process.
It can be set from the linker Settings of the project (for example: /
stack:0x40000,0x1000) , and as far as I understand every thread that
gets created from this process will be given the same (big) stack size
(unless specified otherwise through the flag
STACK_SIZE_PARAM_IS_A_RESERVATION).

But what's happening if this process loads a DLL who is creating some
threads for its own processing?
Would these new threads use the stack size from the parent process? Or
would they use a stack size defined during the linkage of the DLL ?

Actually as I write this it sounds a bit like a dumb question, and I'd
put my money on the later.
But thanks in advance for the clarification.

Cheers,
Alex.

Re: process stack size and threads by portnawake

portnawake
Wed May 16 18:46:16 CDT 2007

OK, it looks like this is not really attracting masses of replies... :
((

I've found some interesting discussions elsewhere. (
http://www.codecomments.com/message534212.html )
specially with this comment at the very bottom of the page :
"It means that it is of no use to specify a stack size in a DLL
project
because it will never be used. Only the stack size specified in the
main EXE
have an effect on every threads of the process."

???? Wow, is that right ????

That would ruin my plans!
At the moment my process is set to have a 96K stack size (same for
every child thread then).
I need to increase the stack size of my main process to 256K, and I'm
thinking of individually setting the stack sizes of every thread that
I create to something like 32K. At the end, this should balance the
impact in terms of VM consumption, and even let me gain some VM.
But if the threads that belong to the third party DLLs in use in my
process are given 256K, that's not acceptable!

Can I have some opinions on this subject?
Cheers,
Alex



On May 14, 5:43 pm, portnaw...@gmail.com wrote:
> Hi,
>
> I've a question / doubt about the option to set the stack size of a
> process.
> It can be set from the linker Settings of the project (for example: /
> stack:0x40000,0x1000) , and as far as I understand every thread that
> gets created from this process will be given the same (big) stack size
> (unless specified otherwise through the flag
> STACK_SIZE_PARAM_IS_A_RESERVATION).
>
> But what's happening if this process loads a DLL who is creating some
> threads for its own processing?
> Would these new threads use the stack size from the parent process? Or
> would they use a stack size defined during the linkage of the DLL ?
>
> Actually as I write this it sounds a bit like a dumb question, and I'd
> put my money on the later.
> But thanks in advance for the clarification.
>
> Cheers,
> Alex.



Re: process stack size and threads by hel

hel
Thu May 17 07:07:49 CDT 2007

pn- [16 May 2007 16:46:16 -0700]:
>At the moment my process is set to have a 96K stack size (same for

It is pointless to set a size to anything but a
multiple of 64K (allocation size granularity).
Memory is not committed except as needed (in
pages). Only 4 KB is typically committed
to start. Nothing new here. The docs you can
find should already cover this well enough.
Avoid the old, obsolete stuff - OS and docs.

--
40th Floor - Software @ http://40th.com/
iplay.40th.com iPlay advanced audio player
zircon.40th.com Zircon mobile music player

Re: process stack size and threads by alexquisi

alexquisi
Thu May 17 07:25:40 CDT 2007

Hi,

I think that this blog entry could be useful you:

http://blogs.msdn.com/kitlfirst/archive/2006/01/31/520197.aspx

regards,

Alex

On May 17, 1:46 am, portnaw...@gmail.com wrote:
> OK, it looks like this is not really attracting masses of replies... :
> ((
>
> I've found some interesting discussions elsewhere. (http://www.codecomments.com/message534212.html)
> specially with this comment at the very bottom of the page :
> "It means that it is of no use to specify a stack size in a DLL
> project
> because it will never be used. Only the stack size specified in the
> main EXE
> have an effect on every threads of the process."
>
> ???? Wow, is that right ????
>
> That would ruin my plans!
> At the moment my process is set to have a 96K stack size (same for
> every child thread then).
> I need to increase the stack size of my main process to 256K, and I'm
> thinking of individually setting the stack sizes of every thread that
> I create to something like 32K. At the end, this should balance the
> impact in terms of VM consumption, and even let me gain some VM.
> But if the threads that belong to the third party DLLs in use in my
> process are given 256K, that's not acceptable!
>
> Can I have some opinions on this subject?
> Cheers,
> Alex
>
> On May 14, 5:43 pm, portnaw...@gmail.com wrote:
>
>
>
> > Hi,
>
> > I've a question / doubt about the option to set the stack size of a
> > process.
> > It can be set from the linker Settings of the project (for example: /
> > stack:0x40000,0x1000) , and as far as I understand every thread that
> > gets created from this process will be given the same (big) stack size
> > (unless specified otherwise through the flag
> > STACK_SIZE_PARAM_IS_A_RESERVATION).
>
> > But what's happening if this process loads a DLL who is creating some
> > threads for its own processing?
> > Would these new threads use the stack size from the parent process? Or
> > would they use a stack size defined during the linkage of the DLL ?
>
> > Actually as I write this it sounds a bit like a dumb question, and I'd
> > put my money on the later.
> > But thanks in advance for the clarification.
>
> > Cheers,
> > Alex.- Hide quoted text -
>
> - Show quoted text -



Re: process stack size and threads by portnawake

portnawake
Thu May 17 16:20:01 CDT 2007

For information, the 96K thing is the current value at the moment, and
it's a legacy of running on earlier versions of CE. Anyway, I need
256...
As far as I understand, it doesn't really matter if the memory is only
committed on demand with 4kb blocks, the stack size is still reserved
and blocks a chunk of the precious virtual memory.

Typically CE devices don't run out of physical memory, it's usually
the 32MB limit of address space that is the main problem. At least in
my case, shortage of VM is a problem. That's why this reserved stack
size does matter a lot to me.
And that's why my question is still outstanding.

This will be old, obsolete stuff when we'll switch to CE6...




On May 18, 12:07 am, h...@40th.com () wrote:
> pn- [16 May 2007 16:46:16 -0700]:
> >At the moment my process is set to have a 96K stack size (same for
>
> It is pointless to set a size to anything but a
> multiple of 64K (allocation size granularity).
> Memory is not committed except as needed (in
> pages). Only 4 KB is typically committed
> to start. Nothing new here. The docs you can
> find should already cover this well enough.
> Avoid the old, obsolete stuff - OS and docs.
>
> --
> 40th Floor - Software @ http://40th.com/
> iplay.40th.com iPlay advanced audio player
> zircon.40th.com Zircon mobile music player



Re: process stack size and threads by hel

hel
Thu May 17 17:54:53 CDT 2007

You either missed my first sentence or don't
understand it. Either way, go back and look.
If you don't understand it (right away), you
have missed (at least) one too many days.

pn- [17 May 2007 14:20:01 -0700]:
>For information, the 96K thing is the current value at the moment, and
>it's a legacy of running on earlier versions of CE. Anyway, I need
>
>> pn- [16 May 2007 16:46:16 -0700]:
>>>At the moment my process is set to have a 96K stack size (same for
>>

Here it is again:

>> It is pointless to set a size to anything but a
>> multiple of 64K (allocation size granularity).
>> ...

--
40th Floor - Software @ http://40th.com/
iplay.40th.com iPlay advanced audio player
zircon.40th.com Zircon mobile music player

Re: process stack size and threads by portnawake

portnawake
Sun May 20 17:14:02 CDT 2007

> Here it is again:
>
> >> It is pointless to set a size to anything but a
> >> multiple of 64K (allocation size granularity).
> >> ...

Yeah, OK, whatever, replace 96k with 128k or 64k if you want, that's
not my point... Sorry this distracted you from answering the real
question...
My question is: if I replace 128 by 256 in my project settings, does
it impact the stack size of the threads from the third party dlls I
use.

Related question:
If a thread in a DLL does some intensively recursive operations and is
given a big 512K stack size in the linker options of the project for
this dll, what happens if it is used by a program set to have "only" a
64K stack size?

Thanks
Alex.