Unexpectedly high RAM usage of model


I’m a novice in ML field and particulary in Edge Impulse so my question may seem stupid, sorry. I tried to find related topics here but looks like I’m the only who faced such problem.
I have successfully built the model for the custom type of sensors. Reported memory estimation is pretty good for me, however when I deloyed model on the real HW I found out that the real RAM usage is much bigger than expected. Below the details.

Expected memory usage as follow:

Attempting to run the model by run_classifier() function invocation fails with an error:
ERR: Failed to run DSP process (-1002)
run_classifier returned: -5

I dig deeper and found that error relates to insufficient memory, so I set beakpoint on memory allocation function call:

__attribute__((weak)) void *ei_calloc(size_t nitems, size_t size) {
	/* ei_printf("Callocing-ing %u\n", nitems * size); */
    return calloc(nitems, size);

Appeared that classifier two times tries to allocate 19864 bytes of memory which is too much, I don’t have enough RAM in system (nRF52832 SoC with BLE enabled).
Can anyone explain why this happened and what I did wrong? Any help is appreciated!

Another one question is about memory optimization. According to the picture above model is optimized for using int8 data type, however I did not found where I can provide data in int8 or int16. Standard callback which fetches data from user buffer accepts only float32, so I have to cast int16 to float32 which definetely affects memory footprint,


Hi @Dmitriy_L

Welcome to the forum,

You can try running the eon compiler to reduce the footprint further:



Hello @Dmitriy_L ,

I just checked the RAM available on that SoC: nRF52832 - Versatile Bluetooth 5.2 SoC - nordicsemi.com
It seems that it has only 32/64kB available. If you enable the BLE, I suspect that you don’t have much left for your ML application.



Hi Eoin,

Thanks for responce. EON compiler is enabled by default. At least at the picture in the start post related switch is ON.


Hello Louis,

Thanks for your input. I’m using 64kB version of nRF52832. On further debug I figured out that declared memory footprint is related to static RAM usage, but much more memory ML model allocates in heap. In my case it takes 6.6K of static and almost 40K dynamic, so I had to enlarge heap area to maximum possible value to run the model, it was quite surprising as I thought that 6.6K is overall amount required for ML.