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

后端 未结 6 1781
栀梦
栀梦 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 11:45

    Use this to compute the amount of memory committed for the current thread's stack:

    function CommittedStackSize: Cardinal;
    asm
      mov eax,[fs:$4] // base of the stack, from the Thread Environment Block (TEB)
      mov edx,[fs:$8] // address of lowest committed stack page
                      // this gets lower as you use more stack
      sub eax,edx
    end;
    

    Another idea I don't have.

提交回复
热议问题