Skip to content

Commit

Permalink
stop cleanupTicker while closing cache (#343)
Browse files Browse the repository at this point in the history
## Problem
`cleanupTicker `that is created in `NewCache` is never stopped, which is
why the code below causes a memory leak

```go
for {
	c, _ := NewCache(...)
	c.Close()
}
```

## Solution
Stop `cleanupTicker` in `Close` method
  • Loading branch information
IlyaFloppy authored Sep 1, 2023
1 parent c00b352 commit 9144662
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func (c *Cache) Close() {
close(c.stop)
close(c.setBuf)
c.policy.Close()
c.cleanupTicker.Stop()
c.isClosed = true
}

Expand Down

0 comments on commit 9144662

Please sign in to comment.