3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test that goroutines and garbage collection run during init.
24 b[i] = byte(i%10 + '0')
28 memstats := new(runtime.MemStats)
29 runtime.ReadMemStats(memstats)
30 sys, numGC := memstats.Sys, memstats.NumGC
32 // Generate 1,000 MB of garbage, only retaining 1 MB total.
33 for i := 0; i < N; i++ {
37 // Verify that the garbage collector ran by seeing if we
38 // allocated fewer than N*MB bytes from the system.
39 runtime.ReadMemStats(memstats)
40 sys1, numGC1 := memstats.Sys, memstats.NumGC
41 if sys1-sys >= N*MB || numGC1 == numGC {
42 println("allocated 1000 chunks of", MB, "and used ", sys1-sys, "memory")
43 println("numGC went", numGC, "to", numGC1)
48 func send(c chan int) {