We have an application which use about 150m on heap after startup,
but some task can make the memory grow up to 700m.
The problem is that after the "memory consuming" task, the JVM don't release it.
So, here is my question : How can I be sure after a memory consuming task that the JVM won't keep the memory for itself when
the really used memory is about 150m and the allocated size is about 1gb ? is there any clean way to notify the JVM that this memory usage was really
temporary and that it should release it for other application ?
That's expected and documented behavior that exists for very valid reasons. If you really must know the how and why, there is plenty of information available like this whitepaper:
Remember: the JVM is a virtual machine which deals with its own memory management. The last thing you want to do is mess with it.
... and that it should release it for other application ?
All modern desktops use virtual memory. That is a feature of the OS which impacts all normal applications including Java VMs.
Some features of virtual memory.
1. Applications have their own addressable memory which is not impacted by other application (normal) usage.
2. Memory that is reserved by an application which is not being actively used does not impact other applications.