summaryrefslogtreecommitdiffhomepage
path: root/pkg/refs
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-10 17:36:36 +0000
committergVisor bot <gvisor-bot@google.com>2020-08-10 17:36:36 +0000
commitea361bd0cdd92a89dd66b692c396eae8e14fb53a (patch)
tree168c12fcb942fb632bd1ad50b22b01f9e816aa0c /pkg/refs
parent6e6151b87b4ebfae504cddff4a88188ca87ae15b (diff)
parent79e7d0b06ac019e3c302e2ab9c5861311304d7d1 (diff)
Merge release-20200804.0-55-g79e7d0b06 (automated)
Diffstat (limited to 'pkg/refs')
-rw-r--r--pkg/refs/refcounter.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go
index 3f39edb66..d9d5e6bcb 100644
--- a/pkg/refs/refcounter.go
+++ b/pkg/refs/refcounter.go
@@ -475,3 +475,13 @@ func (r *AtomicRefCount) DecRefWithDestructor(ctx context.Context, destroy func(
func (r *AtomicRefCount) DecRef(ctx context.Context) {
r.DecRefWithDestructor(ctx, nil)
}
+
+// OnExit is called on sandbox exit. It runs GC to enqueue refcount finalizers,
+// which check for reference leaks. There is no way to guarantee that every
+// finalizer will run before exiting, but this at least ensures that they will
+// be discovered/enqueued by GC.
+func OnExit() {
+ if LeakMode(atomic.LoadUint32(&leakMode)) != NoLeakChecking {
+ runtime.GC()
+ }
+}