3 // Copyright 2013 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 defers do not prevent garbage collection.
21 // Does not work on 32-bits due to partially conservative GC.
22 // Try to enable when we have fully precise GC.
23 if runtime.GOARCH != "amd64" {
30 for i := 0; i < N; i++ {
40 // let the compiler think f escapes
43 runtime.SetFinalizer(v, func(p *int) {
44 atomic.AddInt32(&count, -1)
50 for i := 0; i < 3; i++ {
51 time.Sleep(10 * time.Millisecond)
55 println(count, "out of", N, "finalizer are not called")
56 panic("not all finalizers are called")