Skip to content

Commit d8ece3b

Browse files
author
Sunil Thaha
committed
Reduce memory allocation in callers
This fixes issue #27 by ensuring that `pcs` array allocated on stack does not escape to heap. See issue[1] for details. [1]: #27 Signed-off-by: Sunil Thaha <sthaha@redhat.com>
1 parent 61c3167 commit d8ece3b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

stack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func callers(depth int) *stack {
5959
var pcs [maxDepth]uintptr
6060

6161
n := runtime.Callers(2+depth, pcs[:])
62-
63-
var st stack = pcs[0:n]
62+
st := make(stack, n)
63+
copy(st, pcs[:n])
6464

6565
return &st
6666
}

0 commit comments

Comments
 (0)