What to do with heap?

I noticed this morning that my app is having trouble serving static assets. They take forever before finally erroring with ERR_HTTP2_PROTOCOL_ERROR 200 which I found in another issue has something to do with not enough memory for some reason. I noticed my memory usage is extremely high. So I’m trying to investigate that.

@benbjohnson2 suggested I download a heap of my site in another post for another reason (Site falls over every few hours before rebooting - #32 by benbjohnson2). I got the heap, but I have no idea what to do with it. Is there a tool I can use to investigate the heap and see what the memory is being used for?

EDIT: Also it looks like CPU freaked out as well:

(Note I just redeployed so that’s why it dropped at the end there)

The heap profile is used with the go command. In addition to Go, it’s useful to have the GraphViz installed too:

$ brew install graphviz

Once that’s all installed, you can run:

$ go tool pprof /path/to/heap

There are a bunch of commands in there but I typically use the "web" command which generates a graph of what the current allocations are:

$ go tool pprof /path/to/heap
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) web

You can also use the "pdf" command which does the same thing but generates a PDF which is easier to share.

You can also just send me the heap profile and I can take a look. :slight_smile:

1 Like