Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


vTaskGetRunTimeStats increases flash use

Posted by michal on July 14, 2012

I have an issue with Run Time Stats. Adding vTaskGetRunTimeStats function to my code increases flash use by more than 20kB!
Stats seems to be working fine, but increased flash use doesn't look like a normal behaviour.
Did someone have a similar problem?

Here is the memory use before and after adding vTaskGetRunTimeStats function

text data bss dec
42124 1444 19148 62716
19648 1320 19096 40064

My code is running on STM32 CM3 and use ARM Sourcery GCC Toolchain


RE: vTaskGetRunTimeStats increases flash use

Posted by Richard on 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.


RE: vTaskGetRunTimeStats increases flash use

Posted by michal on July 14, 2012
I added printf-stdarg.c as you suggested and it helped very well! Now only 600bytes more of flash used.
Thank you a lot for your help.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner