mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
debug: Use pprof goroutine writer in debug.Stacks() to ensure all goroutines are captured.
* Up to 64MB limit, previous code only captured first 1MB of goroutines.
This commit is contained in:
parent
eae63c511c
commit
d5868b684b
1 changed files with 9 additions and 3 deletions
|
|
@ -33,6 +33,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -190,9 +192,13 @@ func (*HandlerT) WriteMemProfile(file string) error {
|
||||||
|
|
||||||
// Stacks returns a printed representation of the stacks of all goroutines.
|
// Stacks returns a printed representation of the stacks of all goroutines.
|
||||||
func (*HandlerT) Stacks() string {
|
func (*HandlerT) Stacks() string {
|
||||||
buf := make([]byte, 1024*1024)
|
var b bytes.Buffer
|
||||||
buf = buf[:runtime.Stack(buf, true)]
|
b.Grow(1024 * 1024)
|
||||||
return string(buf)
|
w := bufio.NewWriter(&b)
|
||||||
|
pprof.Lookup("goroutine").WriteTo(w, 2)
|
||||||
|
w.Flush()
|
||||||
|
|
||||||
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FreeOSMemory returns unused memory to the OS.
|
// FreeOSMemory returns unused memory to the OS.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue