[swift-users] hello world takes almost 1MB of RAM

Karl Pickett karl.pickett at gmail.com
Fri Mar 4 15:30:06 CST 2016


On ubuntu 14.4,
$ swiftc -v
Swift version 3.0-dev (LLVM b361b0fc05, Clang 11493b0f62, Swift 24a0c3de75)
Target: x86_64-unknown-linux-gnu

Sample program, compiled with simply "swiftc t.swift".

$ cat t.swift
import Foundation
print("hello, world\n")
while true {
    sleep(1)
}

pmap -XX <pid> shows me 4870KB RSS, 880KB of which is private dirty /
anonymous.  So every additional copy you start takes 880KB of RAM.   (Our
use case has thousands of processes running)

For compariso:
- a dynamically linked C/glibc program takes 88KB
- a dynamically linked C++/glibc,libstdc++ program takes 172KB
- a statically linked C++/glibc,libstdc++ program takes 64KB
- a statically linked musl c program takes just 16KB

Is this on the roadmap for improvement?

- Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160304/c50d45b7/attachment.html>


More information about the swift-users mailing list