How to control Java heap size (memory) allocation (xmx, xms)Use -Xmx to specify maximum heap size and control RAM use in Java programs.