I had a quick play with Rust 0.6 built on my x86-64 machine, using
ps_mem.py (<https://github.com/pixelb/scripts/blob/master/scripts/ps_mem.py>)
to see how much private memory is required for each process. I was
wondering what is the cause of the reasonably large amount of memory
required for each Rust process.
My test program simply prints "hello?" and sleeps for 60 seconds. I
run 5 of these processes, and then collect the memory usage. A full
log is below, but in summary my results for Rust (0.6RC), C (glibc 2.5
and gcc 4.7.2) and Go (1.0.3) are as follows. Results are in format
Private + Shared = Total, see ps_mem.py for the memory accounting
methodology.
Rust:
8.9 MiB + 785.0 KiB = 9.7 MiB hello (5)
C:
452.0 KiB + 55.0 KiB = 507.0 KiB hello (5)
Go:
1.9 MiB + 520.0 KiB = 2.4 MiB hello (5)
Any ideas as to why Rust is so heavy on memory usage (and is there an
existing issue on the bug tracker?)
$ cat hello.rs
fn main() {
io::println("hello?");
unsafe {
libc::sleep(60);
}
}
$ rustc -O hello.rs
$ for i in 1 2 3 4 5; do ./hello & done
$ sudo python ~/ps_mem.py | grep -i hello
8.9 MiB + 785.0 KiB = 9.7 MiB hello (5)
The same for C:
$ cat hello.c
#include <stdio.h>
#include <unistd.h>
int main(void) {
printf("hello?\n");
sleep(60);
return 0;
}
$ gcc -O3 hello.c -o hello
$ for i in 1 2 3 4 5; do ./hello & done
$ sudo python ~/ps_mem.py | grep -i hello
452.0 KiB + 55.0 KiB = 507.0 KiB hello (5)
The same for Go 1.0.3:
$ cat hello.go
package main
import "fmt"
import "time"
func main() {
fmt.Println("hello?")
time.Sleep(60*time.Second)
}
$ go build hello.go
$ for i in 1 2 3 4 5; do ./hello & done
$ sudo python ~/ps_mem.py | grep -i hello
1.9 MiB + 520.0 KiB = 2.4 MiB hello (5)
Thanks,
Alex
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev