What is a safe Maximum Stack Size or How to measure use of stack?

后端 未结 6 1788
栀梦
栀梦 2020-12-15 11:12

I have an app with a number of worker threads, one for each core. On a modern 8 core machine, I have 8 of these threads. My app loads a lot of plugins, which also have their

6条回答
  •  佛祖请我去吃肉
    2020-12-15 12:04

    Even if all 8 threads were to come close to using their 1MB of stack, that's only 8MB of virtual memory. IIRC, the default initial stack size for threads is 64K, increasing upon page-faults unless the process thread-stack limit is reached, at which point I assume your process will be stopped with a 'Stack overflow' messageBox :((

    I fear that reducing the process stack limit $MAXSTACKSIZE will not alleviate your fragmentation/paging issue much, if anything. You need more RAM so that the resident page set of your mega-photo-app is bigger & so thrashing reduced.

    How many threads are there, overall, on average, in your process? Task manager can show this.

    Rgds, Martin

提交回复
热议问题