Skip to content

Commit

Permalink
scheuduled_task: fix memory leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Sep 28, 2024
1 parent e17daf2 commit a63a6ff
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/collector/scheduled_task/scheduled_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const (
SCHED_S_TASK_HAS_NOT_RUN TaskResult = 0x00041303
)

var taskStates = []string{"disabled", "queued", "ready", "running", "unknown"}

type scheduledTask struct {
Name string
Path string
Expand Down Expand Up @@ -192,8 +194,6 @@ func (c *Collector) Collect(_ *types.ScrapeContext, logger *slog.Logger, ch chan
return nil
}

var TASK_STATES = []string{"disabled", "queued", "ready", "running", "unknown"}

func (c *Collector) collect(ch chan<- prometheus.Metric) error {
scheduledTasks, err := c.getScheduledTasks()
if err != nil {
Expand All @@ -206,7 +206,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
continue
}

for _, state := range TASK_STATES {
for _, state := range taskStates {
var stateValue float64

if strings.ToLower(task.State.String()) == state {
Expand Down Expand Up @@ -320,10 +320,6 @@ func (c *Collector) initializeScheduleService(initErrCh chan<- error) {
return
}

defer func(res *ole.VARIANT) {
_ = res.Clear()
}(res)

rootFolderObj := res.ToIDispatch()
defer rootFolderObj.Release()

Expand Down

0 comments on commit a63a6ff

Please sign in to comment.