Report
4 years, 2 months ago.

How can I check for available RAM?

I was wondering if there is any free memory library available, similar to the Memory Free one in Arduino (http://playground.arduino.cc/Code/AvailableMemory). There is one older thread on the topic (https://mbed.org/forum/mbed/topic/433/), but I was wondering if anything was developed meanwhile.

There isn't really a simple answer, since it also depepends on the size of the data you are trying to allocate, but have a look at: https://mbed.org/forum/bugs-suggestions/topic/4809/, for some more recent comments on it, including a way to increase your available RAM.

posted by Erik Olieman 22 Apr 2014
Comment on this question

1 Answer

4 years, 2 months ago.

That is not a simple question to answer in the general case. The problem is that internally an allocator might allocate more memory than requested via malloc(), so simply counting how many bytes you're allocating is often not enough. To further confuse matters, this behaviour is highly dependent on your toolchain. Some allocators offer an interface to their internal implementation (see for example mallinfo()), but again, that's dependent on the allocator. We are going to implement a custom allocator in mbed to handle this kind of situation, but I don't know when that will be ready.


To post an answer, please log in.