Skip to content

Commit

Permalink
pkg/sensors: fix memory use of unloaded sensors
Browse files Browse the repository at this point in the history
Sensors that are disabled are not loaded and should not use memory, thus
we clear the LoadedMapsInfo on unloading programs.

Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Oct 23, 2024
1 parent dd04c6c commit 8e2c979
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sensors/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ func (p *Program) Unload() error {
}
p.unloader = nil
p.unloaderOverride = nil
// The above unloader can succeed while not removing a pin to the program
// because of option.Config.KeepSensorsOnExit, and thus the maps remain.
if !p.Prog.IsPinned() {
p.LoadedMapsInfo = nil
}
return nil
}

Expand Down

0 comments on commit 8e2c979

Please sign in to comment.