diff --git a/mem/buffers.go b/mem/buffers.go index 8832a635e934..48aff208865f 100644 --- a/mem/buffers.go +++ b/mem/buffers.go @@ -30,6 +30,7 @@ import ( "runtime/debug" "sync" "sync/atomic" + "time" ) // A Buffer represents a reference counted piece of data (in bytes) that can be @@ -143,7 +144,7 @@ func (b *buffer) ReadOnlyData() []byte { } func (b *buffer) Ref() { - b.refCallers = append(b.refCallers, fmt.Sprintf("Count: %d, %s", b.refs.Load(), string(debug.Stack()))) + b.refCallers = append(b.refCallers, fmt.Sprintf("Count: %d, time: %s, %s", time.Now(), b.refs.Load(), string(debug.Stack()))) if b.refs == nil { panic("Cannot ref freed buffer") } @@ -155,7 +156,7 @@ func (b *buffer) Track() { } func (b *buffer) Free() { - b.freeCallers = append(b.freeCallers, fmt.Sprintf("Count: %d, %s", b.refs.Load(), string(debug.Stack()))) + b.freeCallers = append(b.freeCallers, fmt.Sprintf("Count: %d, time: %q, %s", time.Now(), b.refs.Load(), string(debug.Stack()))) if b.refs == nil { panic("Cannot free freed buffer") } @@ -205,6 +206,7 @@ func (b *buffer) split(n int) (Buffer, Buffer) { split.origData = b.origData split.data = b.data[n:] split.refs = b.refs + split.refCallers = append([]string{"split"}, b.refCallers...) split.pool = b.pool b.data = b.data[:n]