[En-Nut-Discussion] stack size

Alain M. alainm at pobox.com
Wed Mar 26 23:14:56 CET 2008



Ernst Stippl escreveu:
> Hi Nathan!
> 
> I have already thought about how to find out and document stack space
> requirements for API functions, but I have not found a solution.
> [...]
> What I normally do is trial-and-error. Starting at (size of local vars) plus
> 512 bytes, increasing by 256. If I know there will be quite a number of
> function calls within my own code, I take 1024. 
> 
> How do you tackle that question?

I do something just a little more scientific (in other similar OSes):

When I allocate a stack I clear it all to 0x00. Whenever I am 
interested, I read it all and see how much of the stack is non-zero. 
This is a very fair evaluation of worst case stack usage, specialy if it 
is in some status screen and queried after a very long time the system 
is running.

Another important trick that I had to use sometimes is to change the 
stack for the ISRs that are more consuming. This is not so slow, and can 
reduce overall memory requirement...

Alain




More information about the En-Nut-Discussion mailing list