Questions tagged [pprof]

pprof is a golang package used to profile various runtime properties of golang's http server.

Golang's pprof package serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.

The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.

To use pprof, link this package into your program:

import _ "net/http/pprof"

If your application is not already running an http server, you need to start one. Add "net/http" and "log" to your imports and the following code to your main function:

go func() {
    log.Println(http.ListenAndServe("localhost:6060", nil))
}()

Then use the pprof tool to look at the heap profile:

go tool pprof http://localhost:6060/debug/pprof/heap

Useful links

133 questions
1
vote
0 answers

go tool pprof: no matches found for regexp

cmd:go tool pprof -alloc_objects main.test memprofile.out File: main.test Type: alloc_objects Time: Aug 16, 2023 at 4:33pm (CST) Entering interactive mode (type "help" for commands, "o" for options) (pprof) top Showing nodes accounting for 17323653,…
lixxxxxxon
  • 11
  • 1
1
vote
0 answers

Protobuf marshalling memory efficiency in Go

I have an issue with protobuf marshalling consuming a lot of memory. Over the time it looks like a memory leak: process consumes a lot of heap and finally gets killed by OOM. The service is a networking cache for protobuf objects and the vast…
dkrot
  • 11
  • 3
1
vote
0 answers

golang pprof.Symbol endpoint in net/http/pprof package

How to use pprof.Symbol in Golang net/http/pprof package? This endpoint can handling both 2 GET and POST methods, but I can't understand how can use this method.
Zhasulan Berdibekov
  • 1,077
  • 3
  • 19
  • 39
1
vote
0 answers

Why memory of kube server api in go pprof tool is far less than the memory that actually used?

Our kube api server in master node has one problem recently, its memory keeps growing and will cause OOM kill, now I am looking into this issue and using go pprof tool to check the memory status, but one thing that confused me is that the…
og f91
  • 37
  • 5
1
vote
1 answer

Is go pprof random pick one thread receiving signal

In this article: https://www.datadoghq.com/blog/engineering/profiling-improvements-in-go-1-18/. Below word confusing me:reporting 20 CPU cores being used by top, the expected signal rate should have been 2,000 signals per second. However, the…
jie yang
  • 21
  • 2
1
vote
0 answers

Increasing total samples during CPU profiling with pprof in golang

I am profiling my go application by exposing the /debug/pprof endpoints and obtaining profiles using those endpoints. However, when I run the /debug/pprof/profile for CPU snapshots I see that my total sample is a small portion of overall…
1
vote
1 answer

Golang a huge difference in the number of pprof HeapAlloc and pprof heap inuse_space

I have a Golang program that just implements a simple business logic: establish a socket connection with the server-side program and maintain a business heartbeat. But when this connection does not transmit task data, the pprof report shows that…
Wang
  • 47
  • 3
1
vote
0 answers

Ignore http.Server timeout options for `/debug/pprof`

I am using net/http/pprof package to profile the golang app using a http.Server, which is configured with timeouts: package main import ( "log" "net/http" _ "net/http/pprof" "time" ) func main() { s := &http.Server{ …
slsy
  • 1,257
  • 8
  • 21
1
vote
1 answer

How can I make pprof show every single function in a call tree?

I'm trying to get a full call tree of gpbackup from https://github.com/greenplum-db/gpbackup. I use runtime/pprof, not net/http/pprof, so as far as I know there shouldn't be any time limitations for collecting stats. I start pprof server in a very…
1
vote
1 answer

`go tool pprof` reports error `unrecognized profile format`

I am trying to generate PNG of goroutine profile with this demo, but it reports error parsing profile: unrecognized profile format. failed to fetch any source profiles package main import ( "fmt" "log" "os" "os/exec" …
Dr.Nemo
  • 1,451
  • 2
  • 11
  • 15
1
vote
1 answer

What does pprof -call_tree do?

go tool pprof has a -call_tree option that, according to -help, should “Create a context-sensitive call tree”. However, pprof -tree on a CPU profile gives me the exact same output with and without this option. It looks like this (one representative…
Vasiliy Faronov
  • 11,840
  • 2
  • 38
  • 49
1
vote
2 answers

gperftools not installing -lprofiler on Mac after installing it with brew

Recently I wanted to profile my cpp code and came across gperftool, but there aren't really clear instructions on how to use it with Mac. So far I have run brew install gperftools and wanted to compile my simple cpp file which just outputs "Hello…
Orif Milod
  • 465
  • 1
  • 7
  • 17
1
vote
0 answers

How to analize which object owns the max memory

The Go program contains large memory and I want to know which objects own the max memory. I have try pprof, but it can only show where alloc memory. There is heap dump function, but I can not find any core dump…
loverszhaokai
  • 127
  • 10
1
vote
1 answer

Memory is not being released

This is a simple program to decompress the string, I just running a loop to show that memory usage increases and the memory used never get released. Memory is not getting released even after 8hr also Package for decompressing string:…
Albi
  • 1,705
  • 1
  • 17
  • 28
1
vote
1 answer

How to use pprof to see memory usage by web server after HTTP requests

The documentation for net/http/pprof explains how to create a 30-second CPU profiling session and analyze the outcome. This allows me to initiate one or more HTTP requests and see the resulting CPU utilization of my web application. I see a route…
Tantillo
  • 367
  • 1
  • 5
1 2 3
8 9