Skip to content

Commit

Permalink
Merge pull request #1255 from hangscer8/clean_ticker
Browse files Browse the repository at this point in the history
Stop ticker in time to avoid memory leak
  • Loading branch information
k8s-ci-robot committed Jul 6, 2023
2 parents f02d172 + 698031f commit 9a108c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/nfd-topology-gc/nfd-nrt-gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (n *topologyGC) runGC() {
// periodicGC runs garbage collector at every gcPeriod to make sure we haven't missed any node
func (n *topologyGC) periodicGC(gcPeriod time.Duration) {
gcTrigger := time.NewTicker(gcPeriod)
defer gcTrigger.Stop()
for {
select {
case <-gcTrigger.C:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (n *Notifier) Run() {
timeEvents := make(<-chan time.Time)
if n.sleepInterval > 0 {
ticker := time.NewTicker(n.sleepInterval)
defer ticker.Stop()
timeEvents = ticker.C
}

Expand Down

0 comments on commit 9a108c0

Please sign in to comment.