mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 18:11:03 +00:00
Merge pull request #19 from zplzpl/hotfix/tickerStop
Possible memory leak because of Ticker
This commit is contained in:
commit
639f55c4c9
2
pool.go
2
pool.go
@ -62,6 +62,8 @@ type Pool struct {
|
||||
// clear expired workers periodically.
|
||||
func (p *Pool) periodicallyPurge() {
|
||||
heartbeat := time.NewTicker(p.expiryDuration)
|
||||
defer heartbeat.Stop()
|
||||
|
||||
for range heartbeat.C {
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
|
||||
@ -63,6 +63,8 @@ type PoolWithFunc struct {
|
||||
// clear expired workers periodically.
|
||||
func (p *PoolWithFunc) periodicallyPurge() {
|
||||
heartbeat := time.NewTicker(p.expiryDuration)
|
||||
defer heartbeat.Stop()
|
||||
|
||||
for range heartbeat.C {
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user