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" {
26 // Likewise for gccgo.
27 if runtime
.Compiler
== "gccgo" {
34 for i
:= 0; i
< N
; i
++ {
44 // let the compiler think f escapes
47 runtime
.SetFinalizer(v
, func(p
*string) {
48 atomic
.AddInt32(&count
, -1)
54 for i
:= 0; i
< 3; i
++ {
55 time
.Sleep(10 * time
.Millisecond
)
59 println(count
, "out of", N
, "finalizer are not called")
60 panic("not all finalizers are called")