Is there a way to make JVM act normal so that it wouldn’t require a -Xmx option, and would allocate and free memory directly from the OS just as any normal application would?
That is what it does by default. You only need to set the maximum heap size to indicate at what point you would rather it get an error than use more memory.
Is there some GC which is more efficient, aggressively returning memory to the OS when objects are freed?
I believe the G1 collector in the Oracle JVM is better at this (because it is newer ??)
If I remember correctly, Java has its roots in embedded environments,
It’s root was in Java applets. J2ME was used in embedded systems and this is a different release and code base.
the cumbersome -Xmx is really getting in the way.
I usually don’t set it myself. When you have 128 GB or more it defaults to 32 GB.
3
solved Instructing JVM to use memory like normal processes do?