Monitor Avaliable Ram

chaalar wrote on Wednesday, 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.


nobody wrote on Thursday, 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?

chaalar wrote on Thursday, 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.


nobody wrote on Thursday, 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.

nobody wrote on Thursday, 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