I have an application that temporarily needs some certain amount of memory/heap for some processes. Given a reasonable value of maximum heap size to the JVM as an option, th
The JVM does return memory to the OS, but only very reluctantly, since it may need it again soon, and getting memory from the OS is a relatively expensive operation.
If you want the JVM to return memory to the OS more eagerly, you can use the tuning parameters of the Oracle JVM, specifically -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio