2 years, 6 months ago.
operator new out of memory
I'm pretty new to mbed OS, so I ask you for patience.
When I dynamically allocate memory, it will throw an error : " Operator new out of memory "
My microcontroller has 512 KB RAM. Compiler output statistic shows 85016 bytes of RAM usage. I know that there is no dynamically allocated memory counted, but I don't believe that the rest of memory is used by new operator. Is there any way how to increase HEAP memory?
I tried to use runtime statistics according to this instructions https://docs.mbed.com/docs/mbed-os-handbook/en/5.2/advanced/runtime_stats/ but I'm still getting zeroes. That's probably caused because I appended -DMBED_HEAP_STATS_ENABLED=1 to "mbed compile" command. I know that's probably wrong but I couldn't figure anything else from that instructions.
1 year, 8 months ago.
Same Problem here!
It compiles and runs without a problem in the online compiler. But after exporting to GNU Arm Embedded Toolchain and compiling there, nothing works anymore after uploading the binary to the target, except the message in the serial terminal:
Operator new out of memory
We used the latest mbed OS5 (online compiler) and GNU Arm Embedded Toolchain Version 7-2017-q4-major Linux 64-bit
Frustrating like so many thing with arm mbed!
2 years, 2 months ago.
is your problem still existent? I have kind of the same error. Lots of RAM left, but "Operator new out of memory".
To use Thread Stack statistics you need to set OS_STACK_WATERMARK in the RTX_config.h file to 1. When you want to printf the statistics you need to include "rtx_os.h" To show Stack Size you must call osThreadGetStackSize(osThreadGetId()) To show remaining space in this Stack you must call osThreadGetStackSpace(osThreadGetId()).
When I make Thread Stack bigger, the new operator runs out of memory earlier. I have no explanation for that.
I hope that helped at least a bit.
1 year, 7 months ago.
if you are using multiple threads and having this issue, then the solution is to define the memory allocation for each thread.
Thread threadSample(osPriorityNormal, 2000); allocate 2000 bytes or 2 kilobytes
link to answer is in the mbed OS 5 handbook: https://os.mbed.com/docs/v5.7/reference/configuration.html
You need to log in to post a question