rtel wrote on Saturday, July 14, 2012:
The run time stats code itself is very small, but it makes use of C library functions that are not used anywhere else in the code. As soon as you include run time stats you will be pulling in a lot of extra library functions that can bloat your code, depending on your GCC supplier. Companies such as Rowley and Code Red have their own libraries build specifically for embedded systems. Other suppliers use things like NewLib which is a disaster on a small micro.
There are a couple of things you can do. First, avoid using the libraries that come with your compiler. Normally, this can be done by simply including the printf-stdarg.c source file in your project. Search for it in the FreeRTOS/Demo directory, it is included in a lot of projects. The file implements, in a basic and very stack friendly way, the functions needed by the run time stack. If these functions are defined in your project they will not be pulled in from the compilers libraries.
The second thing you can do is ensure the compiler is configured to remove unused code. Most compilers do that by default, but the GCC default is not to do it so you have to tell it explicitly using the -ffunction-sections and -fdata-sections command line options to the compiler, and the -no-gc-sections linker option.