Go versions: Go version go1.4.2 linux/amd64
Test environment:
[[email protected] mpro]# more /proc/cpuinfo | grep "Model name" model name : intel (R) core (TM) i5-4590 CPU @ 3.30ghzmodel name : intel (R) core (TM) i5-4590 CPU @ 3.30ghzmodel name : intel (R) Core (TM) I5-4590 cpu @ 3.30ghzmodel name : intel (R) Core (TM) i5-4590 CPU @ 3.30GHz[[email protected] mpro]# [[email protected] mpro]# grep memtotal /proc/meminfomemtotal: 3868776 kB[[email protected] mpro]# getconf LONG_BIT64[[email protected] mpro]# more /etc/redhat-releasecentos linux release 7.1.1503 ( Core)
Test Case:
Package Mainimport ("Time") Func main () {for i: = 0; i < 200000; i++ {go func () {time. Sleep (5 * time. Second)} ()}time. Sleep (Ten * time. Second)}
Before executing the program:
Top-18:53:19 up-min, 3 users, load average:0.00, 0.04, 0.11tasks:522 Total, 1 running, 521 sleeping, 0 Stoppe D, 0 zombie%cpu (s): 0.1 us, 0.2 sy, 0.0 ni, 99.6 ID, 0.0 wa, 0.0 hi, 0.1 si, 0.0 stkib mem:3868776 Total, 332 7732 free, 235764 used, 305280 Buff/cachekib swap:2097148 Total, 2097148 free, 0 used. 3397344 Avail Mem
After executing the program:
top-18:53:37 up-min, 3 users, load average:0.00, 0.04, 0.11tasks:524 Total, 1 running, 523 sleeping, 0 Stoppe D, 0 zombie%cpu (s): 1.2 us, 10.6 sy, 0.0 ni, 88.2 ID, 0.0 wa, 0.0 hi, 0.1 si, 0.0 stkib mem:3868776 Total, 279 3732 free, 752512 used, 322532 Buff/cachekib swap:2097148 Total, 2097148 free, 0 used. 2880016 Avail Mem
Summary: 200,000 threads occupy 500M of memory 500,000 kb
Averaging one process takes up 2.5KB
Test the Golang. Resource occupancy