Hi, the way you have it coded is fine. Deleting the net object frees the frame buffer stack along with the heap it uses. If the model was in flash then no frame buffer stack would have actually been used.
The memory allocation failed is the TensorFlow flow arena allocation failing and/or allocation failing when invoking.
Large buffers are allocated when the model you are using runs… and when though you can use gc.collect to cleanup the heap it still fragments which results in allocations potentially failing.
You generally want to not constantly load the model over and over again. If the heap is large enough then this would not have problems… are you on the H7 Plus or RT1062?
…
BTW, please do not comment on a 3 year old thread. This is bad forum etiquette.
Please open a new thread about this topic.