mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
use runtime/debug.Stack() in leak detect test (#2757)
This commit is contained in:
parent
b8903d842c
commit
f7430ec09c
@ -8,7 +8,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -126,9 +126,8 @@ func isIgnoredStackFn(stack string) (ok bool) {
|
|||||||
// pickRelevantGoroutines returns all goroutines we care about for the purpose
|
// pickRelevantGoroutines returns all goroutines we care about for the purpose
|
||||||
// of leak checking. It excludes testing or runtime ones.
|
// of leak checking. It excludes testing or runtime ones.
|
||||||
func pickRelevantGoroutines() (gs []string) {
|
func pickRelevantGoroutines() (gs []string) {
|
||||||
// make a large buffer to hold the runtime stack info.
|
// get runtime stack buffer.
|
||||||
buf := make([]byte, 2<<20)
|
buf := debug.Stack()
|
||||||
buf = buf[:runtime.Stack(buf, true)]
|
|
||||||
// runtime stack of go routines will be listed with 2 blank spaces between each of them, so split on "\n\n" .
|
// runtime stack of go routines will be listed with 2 blank spaces between each of them, so split on "\n\n" .
|
||||||
for _, g := range strings.Split(string(buf), "\n\n") {
|
for _, g := range strings.Split(string(buf), "\n\n") {
|
||||||
// Again split on a new line, the first line of the second half contaisn the info about the go routine.
|
// Again split on a new line, the first line of the second half contaisn the info about the go routine.
|
||||||
|
Loading…
Reference in New Issue
Block a user