GiorgosXou/NeuralNetworks

failed: heap_caps_free heap_caps.c:381 (heap != NULL && "free() target pointer is outside heap areas")

GiorgosXou opened this issue · 0 comments

If you get this error in "serial monitor" when trying to deploy a NN in PROGMEM

failed: heap_caps_free heap_caps.c:381 (heap != NULL && "free() target pointer is outside heap areas")
Core  0 register dump:
MEPC    : 0x40381cdc  RA      : 0x40384d60  SP      : 0x3fc95150  GP      : 0x3fc8ba00  
TP      : 0x3fc8add4  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x3fc952ed  S1      : 0x0000005a  A0      : 0x3fc951b4  A1      : 0x3fc8c98d  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc8f000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3fc951a8  S3      : 0x00000001  
S4      : 0x3fc951a8  S5      : 0x4038215a  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00⸮⸮�⸮⸮	�⸮⸮

Then just add && !defined(USE_PROGMEM) and #if !defined(USE_PROGMEM) to the destructor lines:

#if !defined(REDUCE_RAM_WEIGHTS_COMMON)
for (int j = 0; j < layers[i]._numberOfOutputs; j++) // because of this i wont make _numberOfOutputs/inputs private :/ or maybe.. i ll see... or i will change them to const* ... what? i've just read it again lol
{
delete[] layers[i].weights[j];
layers[i].weights[j] = NULL;
}
#endif

delete layers[i].bias;
layers[i].bias = NULL;

#if defined(REDUCE_RAM_WEIGHTS_LVL2)
delete weights;
weights = NULL;
#endif