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:
- java - Does the JVM give back free memory to the OS when no longer needed? - Stack Overflow
- Why does this java process not release memory? - Stack Overflow
Marco from EOMasters - Mastering Earth Observation