objectleak

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectLeakCheck

type ObjectLeakCheck struct {
	// contains filtered or unexported fields
}

ObjectLeakCheck tracks objects reachable from roots and reports objects that remain reachable after GC.

func NewObjectLeakCheck

func NewObjectLeakCheck(opts ...Option) (ObjectLeakCheck, error)

NewObjectLeakCheck creates an object leak checker.

func (*ObjectLeakCheck) Check

func (t *ObjectLeakCheck) Check() (string, error)

Check settles GC, then returns a full retained-object report and an error for retained objects not covered by expected patterns, expected patterns that no longer match any tracked object, or prune rules that did not match during tracking.

func (*ObjectLeakCheck) Track

func (t *ObjectLeakCheck) Track(root any)

Track walks all values reachable from root and tracks pointer objects it finds.

type Option

type Option func(*ObjectLeakCheck) error

func WithExpected

func WithExpected(pattern string) Option

WithExpected marks retained objects whose reflected path or type name matches pattern as expected. A trailing '*' matches any suffix.

func WithGCSettleTimeout

func WithGCSettleTimeout(timeout time.Duration) Option

WithGCSettleTimeout sets the maximum time Check spends forcing GC and waiting for retained-object counts to settle.

func WithPruneType

func WithPruneType(pattern string) Option

WithPruneType prevents Track from descending into values whose reflected type matches pattern. Named types match their package-qualified name. A trailing '*' matches any suffix.

Jump to

Keyboard shortcuts

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