itchyny / gojq

Pure Go implementation of jq
MIT License
3.3k stars 119 forks source link

Add memory leak tests #258

Closed myaaaaaaaaa closed 2 months ago

myaaaaaaaaa commented 3 months ago

Add memory leak tests using the snippets in #257 as a starting point.

These take the form of benchmarks that fail on excessive memory usage (determined by an environment variable MEM_THRESHOLD), which makes detection simple (just run go test -bench) and investigation straightforward using standard Go profiling tools:

go test -bench=Leak/select -memprofile leak.prof
go tool pprof gojq.test leak.prof

Additionally, make test now also runs these tests so that memory leaks can be found by CI. See the failing checks below for details.

itchyny commented 2 months ago

Even after improving the memory consumption, I'm not planning to include this kind of test, so closing.