Quality RTOS & Embedded Software

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


Monitor Avaliable Ram

Posted by Çağlar Akyüz on September 27, 2006
How can I estimate/monitor the size of free RAM?

I'm using LWiP Webserver Project under GCC for SAM7X. I know the theoric calculation and I think at least there should be 40k avaliable. However, I want to decide avaliable free ram at run time. I'm thinking of calling vPortMalloc and check for return value. Do you I have to arrange heap size or something else for this method to work?

Any other idea is also appreciated.


RE: Monitor Avaliable Ram

Posted by Nobody/Anonymous on September 28, 2006
The kernel heap is internally only used for allocation of RAM to tasks, queues and semaphores. Applications can of coarse use it for anything else they wish.

If your question is how much of the kernel heap RAM remains, rather then total RAM, then the answer depends on the heap implementation you are using.

I don't think you could use heap_1.c with lwIP as it does not implement free. If you were using heap_1 then you could just look at the xNextFreeByte variable.

heap_2.c implements free but does not merge free blocks. I think you could write a simple function that walks the chain of free blocks an adds up their totals.

heap_3.c just uses standard malloc() and free(). Is there a standard function call to ascertain the free heap in this case?

RE: Monitor Avaliable Ram

Posted by Çağlar Akyüz on September 28, 2006
I'm actually interested in Total RAM. Besides, I have some data between 32k-64k. I have SPI RAM for temporary storage and SPI flash for permament storage. I want to calculate how much internal SRAM I can use before using SPI RAMS.

Is it a good idea to increase heap size and dynamically allocate ram from heap or just should I decrease it as much as possible and use off-heap ram.


RE: Monitor Avaliable Ram

Posted by Nobody/Anonymous on September 28, 2006
I should decrease the heap so it just contains the RAM needed by the kernel. Then you can see what is what from your map file.

RE: Monitor Avaliable Ram

Posted by Nobody/Anonymous on September 28, 2006
utility for heap_2.c
2006-09-06 12:26
int vPortUsedMem(void)
xBlockLink *pxBlock = &xStart;
int size = 0;


while ((pxBlock) && (pxBlock != &xEnd))
size += pxBlock->xBlockSize;
pxBlock = pxBlock->pxNextFreeBlock;


return size;

best rgs

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

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

Latest News

Version 10.1.0 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