diff options
Diffstat (limited to 'pkg/refs')
-rw-r--r-- | pkg/refs/refcounter.go | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go index 8c3e3d5ab..ad69e0757 100644 --- a/pkg/refs/refcounter.go +++ b/pkg/refs/refcounter.go @@ -215,8 +215,8 @@ type AtomicRefCount struct { type LeakMode uint32 const ( - // uninitializedLeakChecking indicates that the leak checker has not yet been initialized. - uninitializedLeakChecking LeakMode = iota + // UninitializedLeakChecking indicates that the leak checker has not yet been initialized. + UninitializedLeakChecking LeakMode = iota // NoLeakChecking indicates that no effort should be made to check for // leaks. @@ -231,20 +231,6 @@ const ( LeaksLogTraces ) -// String returns LeakMode's string representation. -func (l LeakMode) String() string { - switch l { - case NoLeakChecking: - return "disabled" - case LeaksLogWarning: - return "log-names" - case LeaksLogTraces: - return "log-traces" - default: - panic(fmt.Sprintf("Invalid leakmode: %d", l)) - } -} - // leakMode stores the current mode for the reference leak checker. // // Values must be one of the LeakMode values. @@ -332,13 +318,15 @@ func (r *AtomicRefCount) finalize() { switch LeakMode(atomic.LoadUint32(&leakMode)) { case NoLeakChecking: return - case uninitializedLeakChecking: + case UninitializedLeakChecking: note = "(Leak checker uninitialized): " } if n := r.ReadRefs(); n != 0 { msg := fmt.Sprintf("%sAtomicRefCount %p owned by %q garbage collected with ref count of %d (want 0)", note, r, r.name, n) if len(r.stack) != 0 { msg += ":\nCaller:\n" + formatStack(r.stack) + } else { + msg += " (enable trace logging to debug)" } log.Warningf(msg) } |