1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-28 02:37:11 +00:00

Stop ticker in time to avoid memory leak

Because it will cause memory leak if we do not stop ticker when the function has completed.

Signed-off-by: hang.jiang <hang.jiang@daocloud.io>
This commit is contained in:
hang.jiang 2023-07-04 13:57:10 +08:00
parent f02d172d07
commit 698031fc2d
2 changed files with 2 additions and 0 deletions

View file

@ -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:

View file

@ -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
}