leak

package
v2.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package leak provide goroutine leak detection using pprof labels instead of stack-trace heuristics.

Instead of parsing runtime.Stack and filtering known system goroutines, we label the tested function's goroutine using pprof.Do.

Child goroutines inherit the label automatically. After the function returns, any goroutines still carrying our label are leaks.

This approach makes leak detection immune to goroutines running concurrently to the leak check (e.g. parallel tests) and immune to background goroutines started by other programs (e.g. database connections, http or grpc pools...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Leaked

func Leaked(ctx context.Context, tested func()) string

Leaked instruments the tested function with a pprof label.

It waits briefly for goroutines to settle, then checks the goroutine profile for any goroutines still carrying our label.

Returns the matching portion of the profile text if leaks are found, or the empty string if clean.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL