Expand description
Sampling heap profiler.
As in jemalloc, a thread takes a sample after a random number of
allocated bytes, exponentially distributed around the sample interval,
so each allocation is sampled with probability 1 - exp(-size / interval). A sample records the allocation’s stack; counts per stack
are scaled by the inverse of that probability, which makes them
unbiased estimates of the real totals.
Sampled allocations live in chunks of their own, so a free only needs to look at the chunk header to know whether it frees a sample.
Structs§
- Sample
- A live sampled allocation, with the fixed point weights it added
Enums§
- Dump
Error - Why a heap profile could not be dumped
Constants§
- DEFAULT_
INTERVAL - 512 KiB, jemalloc’s default (
lg_prof_sample:19)
Functions§
- activate
- Starts sampling allocations
- deactivate
- Stops taking new samples; live samples stay in the profile
- dump_
pprof - The heap profile in pprof’s protobuf format, uncompressed (
pprofreads both plain and gzipped files). Its sample types follow Go’s heap profiles:alloc_objects,alloc_space,inuse_objectsandinuse_space, the default. - is_
active - Whether allocations are being sampled
- sample_
interval - The mean number of bytes between samples
- set_
sample_ interval - Sets the mean number of bytes between samples
- write_
pprof - Writes the heap profile to
path; returns its size in bytes