Test the Golang. Resource occupancy

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Go versions: Go version go1.4.2 linux/amd64

Test environment:

[root@localhost 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[root@localhost  mpro]# [root@localhost mpro]# grep MemTotal /proc/meminfoMemTotal:         3868776 kb[root@localhost mpro]# getconf long_bit64[ root@localhost 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.