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
2
votes
0 answers

Golang - OOM - HeapSys keeps on growing even when HeapAlloc is within acceptable limits

My golang application is deployed in a docker container with 1GB RAM, but over the course of time, the process throws OOM. I thought it would be some memory leak issue, but after analyzing the heap profile of the process from pprof, something seems…
codingenious
  • 8,385
  • 12
  • 60
  • 90
2
votes
0 answers

Profiling global variables

Is it possible to find out the memory usage of global variables in Go? For example have a look at this code: package main import ( "fmt" "math/rand" _ "net/http/pprof" "os" "runtime" "runtime/pprof" "time" ) var…
Hirbod Behnam
  • 577
  • 2
  • 7
  • 26
2
votes
1 answer

Memory is not even getting freed (back to OS)

I'm running a server written in Go and the RSS is very high and the memory is not even getting freed (back to OS). I used pprof to check but it seems that there is no memory leak. I also tried: GODEBUG=madvdontneed=1 ./memorytest Please tell me how…
user10044988
  • 47
  • 1
  • 5
2
votes
0 answers

jemalloc not showing line numbers of go code with cgo

I am using jemalloc using cgo in Go. I also want to get the heap profiles. Currently, I am getting the profiles, but it does not show the corresponding go code. package main /* #cgo LDFLAGS: /usr/local/lib/libjemalloc.a -L/usr/local/lib…
algod
  • 21
  • 5
2
votes
1 answer

Invalid golang profile output format

I've recently started to try out the pprof tools from golang. I have followed the link https://golang.org/pkg/net/http/pprof/ to add a new http server to my service so the profile is able to be accessed. All works fine, but when i try to generate a…
Radhian Amri
  • 327
  • 1
  • 3
  • 11
2
votes
1 answer

`go tool pprof` - how to specify source when using go modules?

I switched to go modules recently and I can't seem to make pprof recognize the source files. Maybe someone here knows how to? I tried using the -source_path and -trim_path options but I can't figure it out how to make it work. Interestingly, typing…
2
votes
2 answers

How to continously profile my go application?

My application is having some memory leaks which makes the application crash often. So I started profiling my application with pprof, but I can get the profile only at the instance I hit the url. Are there any ways to find the profile at some…
Jeffy Mathew
  • 570
  • 4
  • 16
2
votes
0 answers

go tool pprof can't set binary path for local libraries

The have tried to take a pprof dump of a part of our server code that we are trying to optimize. I'm not using the net/http/pprof, rather relying on runtime/pprof. My whole setup works correctly and I'm able to use the pprof dump on the server…
Ishan Khare
  • 1,745
  • 4
  • 28
  • 59
2
votes
1 answer

golang pprof heap count meaning

Description I try to use pprof to profile my programme, and i am using import _ net/http/pprof to add /debug/pprof endpoints in my service. access in browser: http://ip:port/debug/pprof/ then i will have the following page: Everytime when i try…
kvh
  • 2,118
  • 19
  • 29
2
votes
1 answer

convert byte[] to string in golang strange occupy heap

I found strange occupy heap when convert byte[] to string with below code package main import ( "bytes" "fmt" "net/http" _ "net/http/pprof" "strings" "time" ) var ( c = make(chan int, 500000) ) func main() { go func() { …
Nelson
  • 183
  • 3
  • 9
2
votes
0 answers

golang pprof for c library code

I have been trying to profile my golang application with pprof, but it seems that the details of my c code(linked as static library) is missed in the output result. flame graph From the frame graph you can see all the c code time consuming is…
Leon Zhang
  • 53
  • 6
2
votes
0 answers

Go inuse_memory low while residential memory is steadily increasing

I am writing a program in Go that depends on regexp. The memory usage as shown in htop is steadily increasing onto the point where the program is crashing. (> 5-7GB) Yet when I analyze the memory usage with pprof it shows me that only a tiny…
Niels-Ole
  • 129
  • 1
  • 9
2
votes
2 answers

profiling http handler in go lang

I am trying to profile my http handler written in go. Which on every http request download an image from S3, resize it/crop it and write it in response. I have followed this link and tried to profile my code as mentioned using easy method as well…
Naresh
  • 5,073
  • 12
  • 67
  • 124
2
votes
0 answers

Why can't I see my own application functions in golang's pprof

I'm trying to debug the performance characterics of my own program so I'm following the tutorial on the golang blog. But I have 1 small issues I can't investigate the my own functions or call in the resulting profiling output. I'm using this command…
Niels
  • 599
  • 5
  • 28
2
votes
2 answers

Can't see all methods with go pprof

I am using go pprof to profile my application, I have followed the next tutorial - http://saml.rilspace.org/profiling-and-creating-call-graphs-for-go-programs-with-go-tool-pprof And my "--text" result of my profiling is - Total: 48 samples …
Yosi
  • 2,936
  • 7
  • 39
  • 64
1 2 3
8 9