leak

package module
v0.0.0-...-a11b0b9 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2015 License: MIT Imports: 2 Imported by: 1

README

go-leak GoDoc

The std packages of Go do currently not included detection for leaks. go-leak is a package which should help you find leaks in your code. If you have any ideas on how to improve this package or have problems of any kind with it, please submit an issue through the issue tracker.

Note: This package does not work anymore. It worked for some use-cases I had with an older Go version but with >= 1.4 it does not work at all. I have it on my TODO to redo the whole thing and add some more use-cases but there are some other open source projects I have to do first. So if you have some time on your hand and would like to contribute mail me or submit an issue in the project's tracker.

Note: Since Go is scoped it is important to avoid new variables that are in the same scope as the mark-and-release calls.

goroutines

If you want to know if a function is leaking goroutines:

leaks := leak.GoRoutineLeaks(foo)

if leaks > 0 {
	panic("foo is leaking!")
}

If you want to know if a code is leaking goroutines:

m := MarkGoRoutines()

// some code

leaks := m.Release()

if leaks > 0 {
	panic("some code is leaking!")
}

memory

If you want to know if a function is leaking memory:

leaks := leak.MemoryLeaks(foo)

if leaks > 0 {
	panic("foo is leaking!")
}

If you want to know if a code is leaking memory:

m := MarkMemory()

// some code

leaks := m.Release()

if leaks > 0 {
	panic("some code is leaking!")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoRoutineLeaks

func GoRoutineLeaks(f func()) int

func MemoryLeaks

func MemoryLeaks(f func()) int

Types

type GoRoutineMark

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

func MarkGoRoutines

func MarkGoRoutines() *GoRoutineMark

func (*GoRoutineMark) Release

func (m *GoRoutineMark) Release() int

type MemoryMark

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

func MarkMemory

func MarkMemory() *MemoryMark

func (*MemoryMark) Release

func (m *MemoryMark) Release() int

Jump to

Keyboard shortcuts

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