Extracting the logic for parsing heap_size to Util.parse_ram_size_to_m

This is to allow future (and external) reuse of this logic. The exact
reuse I have in mind is implementing a method for -XX:MaxDirectMemorySize.