Have you ever wondered about the least amount of memory a C or Go program will use on a 64bit Linux machine? Kr & I have, here is the results of our curiosity:
A simple C program:
void
main()
{
for (;;) {
}
}
A simple Go program (go1.0.3):
package main
func main() {
for {
}
}
Observe the memory usage:
$ ps -p 16604,16607 -o comm,vsize,rss
COMMAND VSZ RSS
go 34652 252
c 4148 352
The ratio of virtual/resident is quite different. In fact, if we ulimit
our shell with 8192KB of memory, we can't even start our Go process.
$ ulimit -v 8192
$ ./go
Killed
$ ./c
Interesting that C had a larger working set.