For years java was synonyms of greedy applications, the kind that opens the refrigerator at night and eat all the available resources until the crash. The main reason for that behavior was the lack of an efficient way to give back the operational system the memory allocated in the java heap and not used anymore.
However with the new feature released on OpenJDK 12 for Automatic Vertical Scaling of the java Heap in combination with Shenandoah Garbage Collector algorithm the JVM now is able to dynamically scale the java heap and give back the committed memory to the SO when necessary. That´s an amazing feature that will allow you to save money when running your microservice application on a cloud environment that usually fees you by the used resource.