Go Wiki: heapdump15-through-heapdump17

Heap dump format for other versions:

Introduction

Go 1.5 has a runtime/debug.WriteHeapDump function that writes all objects in the heap plus additional info (roots, goroutines, finalizers, etc.) to a file. The format of this file is specified here.

Details

The file starts with the bytes of the string “go1.5 heap dump\n”. This description also applies to files starting with “go1.6 heap dump\n” and “go1.7 heap dump\n”. The go1.6 format is identical to 1.5, and the go1.7 format has one small change described below.

The rest of the file is a sequence of records. Records can be of several different kinds. Records will contain the following primitives:

Each record starts with a uvarint-encoded integer describing the type of the record:

The remaining fields of each record are type-dependent and are described below.

EOF

An EOF record has no fields and must appear last.

object

The size of the contents string is the size of the containing sizeclass, not the size of the object itself. As such, contents size may be somewhat bigger than the contained object’s type.

otherroot

type

goroutine (G)

Possible statuses:

The wait fields must be present in all cases, but they only mean something if the status is “waiting”.

stack frame

dump params

finalizer

This finalizer has been registered with the runtime system, but the object to which it refers was either reachable as of the most recent GC or allocated since the most recent GC.

itab

osthread (M)

memstats

Records the following fields of runtime.MemStats:

queuedfinalizer

This finalizer is ready to run - the object to which it refers is unreachable. The runtime system just hasn’t gotten around to running it yet.

data

bss

Same format as data, but for the bss segment.

defer

panic

alloc/free profile record

alloc sample record


This content is part of the Go Wiki.