Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/debug: use pprof goroutine writer for debug_stacks #16892

Merged
merged 4 commits into from
Jun 14, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/debug/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package debug

import (
"bytes"
"errors"
"io"
"os"
Expand Down Expand Up @@ -190,9 +191,9 @@ func (*HandlerT) WriteMemProfile(file string) error {

// Stacks returns a printed representation of the stacks of all goroutines.
func (*HandlerT) Stacks() string {
buf := make([]byte, 1024*1024)
buf = buf[:runtime.Stack(buf, true)]
return string(buf)
var b bytes.Buffer
pprof.Lookup("goroutine").WriteTo(w, 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjl w -> b.

return b.String()
}

// FreeOSMemory returns unused memory to the OS.
Expand Down