Skip to main content
Renesas Electronics America - Knowledgebase

If I use printf() how much memory do I need to set aside in my thread?

Latest Updated:07/27/2016


If I use printf() how much thread memory will it take?


When using (s)printf you need to make sure the calling thread has a stack size of at least 2K (4K is even better). You can also build the project with the nano version of the standard library to reduce the stack and heap usage. This is done via C/C++ Build >> Settings >> Cross ARM C Linker >> Miscellaneous page in project properties. Here are some rules of thumb (your mileage may vary):

500 of stack for each hal driver
1-2k stack for each framework depending how complex it is
2k if sprintf is used