Go Wiki: heapdump14

Heap dump format for other versions:

Introduction

Go 1.4 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.4 heap dump\n”.

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

Dumps the first 26 fields of MemStats. All fields are dumped with a uvarint except the 25th which is dumped with 256 uvarints.

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.