Why SNAP doesn't clear memory after closing the products?

I open product(s) visualize them, add a couple of shapefiles then close the window and close the product completely but still SNAP occupies significant memory. You can see it on the screenshot below (attachment), it was over 9000 MB before I took the screenshot and at that moment memory of the device was 97% full, I’m sure if I had more memory SNAP would occupy that as well. Shouldn’t the program clear the memory when there is no product opened? Should I close and open the program again every time just to free up the memory? When I reopen the SNAP it just uses under 600 MB of RAM.

Java manages the allocated memory. SNAP can only mark the memory as not used anymore. Which it does (in most cases).
You can enable a little performance widget in SNAP. Click on the toolbar and select Performance.
You will now see a memory graph, showing the used and the allocated memory values.
Clicking on the graph tells Java/SNAP to free used memory immediately.
The first number, the used memory, will get smaller but the second, the allocated memory, stays almost the same. Windows only shows the allocated memory.
Java does return memory to the OS, but only very reluctantly, since it may need it again soon, and getting memory from the OS is an expensive operation. So, Java keeps the memory for performance reasons.
If your OS is really out of memory and other applications request memory, Java will give back memory.
SNAP is configured by default to use 75% (if I remember correctly) of your memory. This and other settings influence the behaviour when memory is returned to the OS.

Here two links to Stackoverflow which discuss this beviour two:

EOMasters_icon_60 Marco from EOMasters - Mastering Earth Observation

1 Like

This helped. Thank you very much!