leakcheck

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package leakcheck fails a test binary that finishes with resources still held.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Leaked

func Leaked(checks ...Check) string

Leaked waits for every check to drain and returns the report of those that did not, or "" when all are clean.

func Main

func Main(m *testing.M, checks ...Check)

Main runs the tests of m and, when they all pass, fails the binary if any check still reports a leak after it had time to settle. It is meant for TestMain:

func TestMain(m *testing.M) { leakcheck.Main(m, leakcheck.Counter("owner pins", vectorized.OutstandingOwnerPins)) }

Set BYDB_LEAK_STACKS=1 to track where pooled objects were acquired.

Types

type Check

type Check func() string

Check returns a description of what is still held, or "" when nothing is.

func Counter

func Counter(name string, count func() int64) Check

Counter is a check on a count that must return to zero.

func Pools

func Pools(prefixes ...string) Check

Pools is a check that every pool whose name starts with one of prefixes has nothing checked out. A pool whose objects are also created outside it and then released into it counts below zero, so use it only for pools every object of which is taken from the pool. It passes trivially in slim builds.

Jump to

Keyboard shortcuts

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