allegro / bigcache

Efficient cache for gigabytes of data written in Go.
http://allegro.tech/2016/03/writing-fast-cache-service-in-go.html
Apache License 2.0
7.45k stars 593 forks source link

Whether it is a bug ? #357

Open Jay-deng opened 1 year ago

Jay-deng commented 1 year ago

When I use Uber's goleak to run the test function TestWriteAndGetOnCache() in https://github.com/allegro/bigcache/blob/master/bigcache_test.go, I got the following output information. I was wondering if it is a bug ?

1 2

You can reproduce it like this:

截屏2023-02-14 16 53 29
janisz commented 1 year ago

Nice catch. Probably we should call defer cache.Close() after cache is created to prevent such leak. https://github.com/allegro/bigcache/blob/982ec3b09cacb9936b88dcfdaed329870065cf23/bigcache.go#L122-L125