FDio / govpp

Go toolset for the VPP.
Apache License 2.0
193 stars 82 forks source link

Fix: memory leak in receiveReplyInternal function #120

Closed e-nikolaev closed 1 year ago

e-nikolaev commented 1 year ago

Function receiveReplyInternal uses 2 control timers: timeoutTimer and slowTimer.

Need to stop these timers before exit from the function (using defer) to avoid memory leak:

    timeoutTimer := time.NewTimer(timeout)
    slowTimer := time.NewTimer(slowReplyDur)
    defer func() {
        timeoutTimer.Stop()
        slowTimer.Stop()
    }()

I met the problem in our production environment while using very repeatetive dumping IP routes. My temp solution fixed the memory leak.