Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether it is a bug ? #357

Open
Jay-deng opened this issue Feb 14, 2023 · 1 comment
Open

Whether it is a bug ? #357

Jay-deng opened this issue Feb 14, 2023 · 1 comment
Labels

Comments

@Jay-deng
Copy link

Jay-deng commented Feb 14, 2023

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

@Jay-deng Jay-deng added the bug label Feb 14, 2023
@janisz
Copy link
Collaborator

janisz commented Feb 14, 2023

Nice catch. Probably we should call defer cache.Close() after cache is created to prevent such leak.

bigcache/bigcache.go

Lines 122 to 125 in 982ec3b

// Close is used to signal a shutdown of the cache when you are done with it.
// This allows the cleaning goroutines to exit and ensures references are not
// kept to the cache preventing GC of the entire cache.
func (c *BigCache) Close() error {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants