Mem Alloc Failed - dispite having ample 'free()' memory #14143
-
I am seeing memory issues, again. This time is to a call to a 3rd party 'config' library When my code issue a call to update the config (file), it fails with error about allocating 1148 bytes. My code, with
Error printed, via UART console. Timestamping on the PC with GrabSerial script.
I don't know if I can reduce this to a simple example, but I can put SWD/GDB into action given some guidance. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
On frequency of issue: ~2 out of 10 calibration runs, but seemingly random. Each run is 10mins, unit powered off in between.
|
Beta Was this translation helpful? Give feedback.
-
It was suggested to try Here's an example where alloc also failures afterwards.
|
Beta Was this translation helpful? Give feedback.
-
See errors But in trying this library: it does very non-library things. Is it trying to write to itself? Yes it is! Eek! Please consider using json for persistent storage instead. |
Beta Was this translation helpful? Give feedback.
-
I think I have a solution. I may have to re-consider the 'config solution' in the future, but for now this it is NOT the problem. Looking at the The dumb thing is that these are used during the calibration process, but not needed afterwards. I even have a Add the These show how much I was able to recover. |
Beta Was this translation helpful? Give feedback.
I think I have a solution.
I may have to re-consider the 'config solution' in the future, but for now this it is NOT the problem. Looking at the
mem_info()
output (and reading what it it all means) made me realize that the memory is heavily fragmented with 'F' all over the place - I made the connection that these are from the 'rolling average' class I have.The dumb thing is that these are used during the calibration process, but not needed afterwards. I even have a
purge()
function in the class, which I was not calling.... D'oh.Add the
purge()
before writing to the config and all is well. 40 calibration cycles, across two units and no errors.These show how much I was able to recover.
b…