How does rust use such little memory compared to java?
I have recently started learning java and have been doing some leetcode problems with it. I implemented a solution in java then using the exact same code I did it in rust.
Runtimes were the same but the memory was hugely different.
Java was over 40mb,
Rust was 2.2mb
Is this because rust is compiled so the compiler knows exactly what it needs in terms of memory before creating the binary?
Or is it to do with java running on a JVM which uses up some memory on it’s own?