I'm trying to measure the memory size of a rust program I'm writing. I noticed that when I measure the heap size with the command:
valgrind --tool=massif --pages-as-heap=yes ./program
And measure using ms_print, that the memory size was quite large (intially around 16MB). Eventually, I reduced my rust program to an empty main function:
fn main() {
}
And I compiled, and still had 16MB as my memory size. I noticed that when I used a different machine, the very same binary would be 4MB in total size. One of my friends tried this with the same program on his machine, with the same rust/valgrind version and got 4MB of size as well.
I imagine this is some sort of pre-allocation to memory that might be used in the heap, but I can't figure out any way to control it. I even tried changing my allocator following this guide, but nothing changed.
System details:
OS version = Ubuntu 18.04
valgrind version = valgrind-3.13.0
cargo version = cargo 1.39.0-nightly (3f700ec43 2019-08-19)
rustc version = rustc 1.39.0-nightly (e44fdf979 2019-08-21)
ms_print = ms_print-3.13.0
libc version = ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27