mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats. The new accessor requires passing a pointer to a user-allocated MemStats structure. Fixes #2572. R=bradfitz, rsc, bradfitz, gustavo CC=golang-dev, remy https://golang.org/cl/5616072
This commit is contained in:
parent
9c060b8d60
commit
842c906e2e
23 changed files with 129 additions and 105 deletions
|
|
@ -10,20 +10,21 @@ import (
|
|||
)
|
||||
|
||||
func TestGcSys(t *testing.T) {
|
||||
memstats := new(runtime.MemStats)
|
||||
runtime.GC()
|
||||
runtime.UpdateMemStats()
|
||||
sys := runtime.MemStats.Sys
|
||||
runtime.ReadMemStats(memstats)
|
||||
sys := memstats.Sys
|
||||
|
||||
for i := 0; i < 1000000; i++ {
|
||||
workthegc()
|
||||
}
|
||||
|
||||
// Should only be using a few MB.
|
||||
runtime.UpdateMemStats()
|
||||
if sys > runtime.MemStats.Sys {
|
||||
runtime.ReadMemStats(memstats)
|
||||
if sys > memstats.Sys {
|
||||
sys = 0
|
||||
} else {
|
||||
sys = runtime.MemStats.Sys - sys
|
||||
sys = memstats.Sys - sys
|
||||
}
|
||||
t.Logf("used %d extra bytes", sys)
|
||||
if sys > 4<<20 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue