Closed
Description
by matusis:
What does 'go version' print? go version go1.3 linux/amd64 This program http://play.golang.org/p/vnKYk3sO5d creates 100000 goroutines, with each goroutine allocating some memory and then finishing. The program prints RES memory of the process as seen by "top" and also prints runtime.ReadMemStats every 25 minutes. 1. Build the program from http://play.golang.org/p/vnKYk3sO5d on a server and run it 2. Wait at least for 50 minutes for two printouts What happened? After 50 minutes, the program produces output like this: Creating 100000 goroutines PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19155 alecm 20 0 151m 84m 760 S 0 0.5 0:01.46 bugrep1.3 Free #0; HeapAlloc: 10531984, HeapInuse: 10813440, HeapReleased: 0, HeapObjs: 36575 Done creating goroutines, freeing memory (every 25 mins) PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19155 alecm 20 0 151m 79m 836 S 2 0.5 0:01.69 bugrep1.3 Free #1; HeapAlloc: 5492784, HeapInuse: 5791744, HeapReleased: 5742592, HeapObjs: 18014 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19155 alecm 20 0 151m 79m 860 S 0 0.5 0:01.88 bugrep1.3 Free #2; HeapAlloc: 5494912, HeapInuse: 5791744, HeapReleased: 5742592, HeapObjs: 18061 The program released only 5MB or RES memory after 50 min. HeapReleased value matches RES drop displayed by "top". What should have happened instead? Since goroutines exit and the slices created in them are not stored, most memory (>80MB) should be returned to the OS. Only 5MB is returned however. PS. We first saw this behavior in a simple TCP server accepting, reading from and closing 10000 connections: please see https://groups.google.com/forum/#!topic/golang-nuts/0WSOKnHGBZE
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
davecheney commentedon Jun 25, 2014
Comment 1:
Status changed to WaitingForReply.
siritinga commentedon Jun 25, 2014
Comment 2:
davecheney commentedon Jun 25, 2014
Comment 3:
dvyukov commentedon Jun 26, 2014
Comment 4:
Labels changed: added release-go1.4, repo-main.
Owner changed to @dvyukov.
Status changed to Accepted.
rsc commentedon Sep 16, 2014
Comment 6:
Status changed to Fixed.
dvyukov commentedon Sep 16, 2014
Comment 7:
Status changed to Accepted.
gopherbot commentedon Sep 17, 2014
Comment 8:
randall77 commentedon Sep 17, 2014
Comment 9:
This issue was closed by revision 92eb1e1.
Status changed to Fixed.
gopherbot commentedon Sep 29, 2014
Comment 10 by kirillrdy:
ianlancetaylor commentedon Sep 29, 2014
Comment 11:
siritinga commentedon Sep 29, 2014
Comment 12:
runtime: free stacks of Gdead goroutines at GC time
runtime: free stacks of Gdead goroutines at GC time
runtime: free stacks of Gdead goroutines at GC time