Java takes flags for min/initial/max memory that, as a strict law of nature, are always wrong the first time you try. And it holds onto unused memory unless you pass another flag. Idk exactly why there's no reasonable default for that, but probably cause it's in a VM. No other language has this problem.
The Java "compiled" code isn't a native binary like in Go, it really does run in a VM. I honestly don't know if that's why they handle memory differently though.