Hello! I am having problems managing memory. To provide some context, I am using a neural network with the new ML library on an OpenMV H7 board. It works well when I use it with the “mobilenet detection” example provided by the IDE. I embedded my network into the firmware and have been cleaning up variables so it can be used in a real application that I have been developing. Today, I realized that even though I have more memory than needed, I still keep getting this memory allocation error. I would appreciate any help you can provide. Here is a part of the code I am using and the error output.
def InferenceAI(blobList, img):
labels=[]
objectsDetected=[]
gc.collect()
print("Free memory: {} bytes".format(gc.mem_free()))
print("Used memory: {} bytes".format(gc.mem_alloc()))
net = ml.Model("detection_custom") ## Error line
Free memory: 273264 bytes
Used memory: 19872 bytesTraceback (most recent call last):
File “”, line 604, in
File “”, line 433, in InferenceAI
File “ml/model.py”, line 14, in init
MemoryError: memory allocation failed, allocating 239091 bytes
239091 bytes are needed but I have 273264 free to use