-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Addressing strange memory leak #59
Comments
@gonejack Thanks! So I can fix this problem🙏 |
func TestMemory(t *testing.T) {
c := New[string, int](AsLRU[string, int](lru.WithCapacity(100)))
for i := 0; i < 1e7; i++ {
c.Set(fmt.Sprint(i), i, WithExpiration(time.Second))
}
time.Sleep(time.Second * 2)
fmt.Printf("len(c.expManager.queue)=%d\n", len(c.expManager.queue))
fmt.Printf("cap(c.expManager.queue)=%d\n", cap(c.expManager.queue))
fmt.Printf("len(c.expManager.mapping)=%d\n", len(c.expManager.mapping))
} Image we are doing something like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
go-generics-cache/cache.go
Lines 277 to 279 in 2601bb0
After some pprof job, I believe this line make memory leaks as this would not checking lru cache capacity before doing heap push.
The text was updated successfully, but these errors were encountered: