Getting random "free() target pointer is outside heap areas" (ESP32-EYE)

My dataset built from 149 images, for testing. I’m using ESP32-EYE (4MB/8MB).
I Deployed my project with both “float32” and “int8”.
In both, while trying to detect directly from the device (edge-impulse-run-impulse), i’m getting randomly(or depends on the image content?!):
"Taking photo…
E (1060049) CameraDriver: Camera Capture Failed
ERR: Failed to take a snapshot!

assert failed: heap_caps_free heap_caps.c:304 (heap != NULL && “free() target pointer is outside heap areas”)

Backtrace:0x40082151:0x3ffbda900x4008ba49:0x3ffbdab0 0x400910c9:0x3ffbdad0 0x40082373:0x3ffbdc00 0x40091121:0x3ffbdc20 0x400d78fd:0x3ffbdc40 0x400dfa26:0x3ffbdc60 0x400dff9d:0x3ffbdd10 0x400da201:0x3ffbdd40 0x40142345:0x3ffbdd60 0x400d7e89:0x3ffbdd80 0x400d8bfc:0x3ffbde00 0x400d7821:0x3ffbdf10 0x4014588a:0x3ffbdf30 "

Project ID:

Context/Use case:
Trying to detect only two classes.


Hello @tamir,

It seems like a memory issue, could you try to use the FOMO model with an alpha of 0.1 and/or a smaller image (64x64px for example)



Hi @louis,

Thanks for reviewing my question.
I changed to alpha 0.1/64x64, and still getting that error a lot.
It’s indeed, looks like a memory issue but i’m not sure on how to solve that.
What I learned from more few tests is that it depends on the amount of objects that in the image.
My model trained to detect two classes. It looks like when the device detect 2-3 objects it works fine, but when there are more objects, it cause to that error.

Is there a way to optimize that?


Okay, I deployed your project and was able to reproduce the issue. In a nutshell it was a few issues piled on top on another actually, but the root cause was that ESP was not able to process the images fast enough for complex scenes. Read some discussion here

I’ll place the fixes to the upcoming PR for ESP32, which should be merged next week. If it is urgent I can tell you where you need to make changes (it is quite a few places though).
I tested with camera detecting up to 7 objects - not sure how further it can be pushed, since we don’t have a test for that.
Predictions (DSP: 7 ms., Classification: 519 ms., Anomaly: 0 ms.):
xxx (0.878906) [ x: 32, y: 48, width: 16, height: 8 ]
xxx (0.566406) [ x: 56, y: 48, width: 8, height: 8 ]
xxx (0.917969) [ x: 72, y: 48, width: 16, height: 8 ]
xxx (0.652344) [ x: 16, y: 56, width: 8, height: 8 ]
xxx (0.894531) [ x: 40, y: 64, width: 8, height: 16 ]
xxx (0.511719) [ x: 56, y: 72, width: 8, height: 8 ]
xxx (0.503906) [ x: 64, y: 88, width: 8, height: 8 ]

1 Like

Thanks so much Dmitry @AIWintermuteAI for testing this issue and even reproduced it.
That’s good to know that it’s confirmed and not something that is only on my setup.
I reviewed the case that you mentioned and indeed, it looks like the same memory issue when more objects are detected in an image.
This is not urgent and I can wait for the PR to be merged, but just for curiosity and for the knowledge sharing with the community, it will be good to add some notes about what can solve that.
If you can share the PR itself, I will be able to review the changes and also follow it, when it’s ready. Thank you!!
I really appreciate your help and support!

1 Like