summaryrefslogtreecommitdiff
path: root/test/init1.go
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2012-02-06 19:16:26 +0100
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2012-02-06 19:16:26 +0100
commit842c906e2e9560187d4877d9f52e8f9ceb63d84c (patch)
tree218df3c83f3177d2f8ceccf20898d8e037c37042 /test/init1.go
parent9c060b8d60f14d930e5eadd7c9968ee2ba4f4131 (diff)
downloadgo-git-842c906e2e9560187d4877d9f52e8f9ceb63d84c.tar.gz
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
Diffstat (limited to 'test/init1.go')
-rw-r--r--test/init1.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/init1.go b/test/init1.go
index 9ce3c12ee6..56ef17249f 100644
--- a/test/init1.go
+++ b/test/init1.go
@@ -16,10 +16,11 @@ func init() {
c := make(chan int)
go send(c)
<-c
-
- const chunk = 1<<20
- runtime.UpdateMemStats()
- sys := runtime.MemStats.Sys
+
+ const chunk = 1 << 20
+ memstats := new(runtime.MemStats)
+ runtime.ReadMemStats(memstats)
+ sys := memstats.Sys
b := make([]byte, chunk)
for i := range b {
b[i] = byte(i%10 + '0')
@@ -28,8 +29,8 @@ func init() {
for i := 0; i < 1000; i++ {
x = []byte(s)
}
- runtime.UpdateMemStats()
- sys1 := runtime.MemStats.Sys
+ runtime.ReadMemStats(memstats)
+ sys1 := memstats.Sys
if sys1-sys > chunk*50 {
println("allocated 1000 chunks of", chunk, "and used ", sys1-sys, "memory")
}
@@ -41,4 +42,3 @@ func send(c chan int) {
func main() {
}
-