| // Copyright 2013 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Test that defers do not prevent garbage collection. |
| // Does not work on 32-bits due to partially conservative GC. |
| // Try to enable when we have fully precise GC. |
| if runtime.GOARCH != "amd64" { |
| if runtime.Compiler == "gccgo" { |
| // let the compiler think f escapes |
| runtime.SetFinalizer(v, func(p *string) { |
| atomic.AddInt32(&count, -1) |
| time.Sleep(10 * time.Millisecond) |
| println(count, "out of", N, "finalizer are not called") |
| panic("not all finalizers are called") |