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
commit71f9a05e783532e348b78ac6696a9bd2b64c90d6 (patch)
tree21b5b46e4adf5b7fd3e5753ccb3dcddbd20ede67 /test/init1.go
parenta899195ae7479be02c2d4212f316698e123b471c (diff)
downloadgo-71f9a05e783532e348b78ac6696a9bd2b64c90d6.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 issue 2572. R=bradfitz, rsc, bradfitz, gustavo CC=golang-dev, remy http://codereview.appspot.com/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 9ce3c12ee..56ef17249 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() {
}
-