Comments (1)
You need to defer leaktest.Check(t)()
Pretty much what happens is
leaktest.Check(t)
takes a snapshot of all current goroutine stacks and returns a function, when that function is called, it takes another snapshot and diffs the two. In a sense, it's actually doing
snapshotFn := leaktest.Check(t)
defer snapshotFn()
but defer leaktest.Check(t)()
works because the first call to Check is evaluated long before the defer.
Even though Go is garbage collected, the GC will not clean up a running goroutine, so if you have a function that launches many stalled goroutines, each will take up a minimum of 4k of memory that will never be repaired.
Hopefully this helps!
from leaktest.
Related Issues (18)
- Prevent broken usage HOT 1
- Tests fail with "unexpected fault address 0x117160" for aarch64 HOT 3
- Tests hang in simple for loop HOT 3
- Timeouts happen immediately HOT 3
- README example is missing a () HOT 1
- Tagging releases HOT 3
- Ignore HTTP Keep-alives
- Clarify Licensing
- Feedback from r/golang
- Error parsing stack HOT 4
- Adding go modules support HOT 3
- Cannot install: write: socket is not connected HOT 1
- Plans for supporting t.Parallel HOT 7
- Test timeouts HOT 1
- More test cases HOT 2
- tip vs the rest HOT 4
- Does not work with go 1.7 HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaktest.