Skip to main content

set_default_sampling_distance

Function set_default_sampling_distance 

Source
pub fn set_default_sampling_distance(distance_bytes: u64)
Expand description

Set the default mean sample distance (bytes between samples) for the heap sampler.

The sampler draws from an exponential distribution around this mean, so individual gaps vary but average to the configured value. Pass 0 to revert to the compiled-in default (512 KiB). Values below 64 KiB are clamped to 64 KiB to avoid excessive overhead.

Call this at the top of main, before the application’s allocation-heavy work begins. Threads that have already initialized their sampler state will not pick up the new value.