Deallocate all of the memory allocated on heap

Is there a function that in micropython that deallocates all the memory on heap?
I actually wish to implement the following thing

while(True):
    img = sensor.snapshot()
    # do some manipulation on image , copy image and store some data out of it
    # deallocate all the memory assigned to heap

is there a way to deallocate this memory which stores copied image and some data variables ??

Snapshot stores the image on a giant stack called the frame buffer. This is managed for you.

You can copy images to the heap if you want. You can’t manually “delete” any python lvalue and it will be freed. However, the images are stored again in the frame buffer stack.