3 // Copyright 2018 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.
24 // encourage heap object to be collected, and have its finalizer run.
33 gc() // prior to stack objects, heap object is not collected until here
35 panic("heap object never collected")
38 panic(fmt.Sprintf("expected collection at phase 1, got phase %d", c))
45 runtime.SetFinalizer(s.h, func(h *HeapObj) {
46 // Remember at what phase the heap object was collected.
54 gc() // heap object is still live here
56 gc() // heap object should be collected here