-
Notifications
You must be signed in to change notification settings - Fork 811
Closed
Description
I had a very serious memory leak when using elasticsearch_exporter to collect metrics, which was causing my app to OOM every few hours in production.
Through the analysis of the pprof tool, the memory usage is relatively large as follows:

After analyzing the code, it is found that in the Run function of the clusterinfo module, a TimeTicker is defined but it is not stopped.
go func(ctx context.Context) {
if r.interval <= 0 {
r.logger.Info("no periodic cluster info label update requested")
return
}
ticker := time.NewTicker(r.interval)
for {
select {
case <-ctx.Done():
r.logger.Info(
"context cancelled, exiting cluster info trigger loop",
"err", ctx.Err(),
)
return
case <-ticker.C:
r.logger.Debug("triggering periodic update")
r.sync <- struct{}{}
}
}
}(ctx)When this function is requested on a regular basis, a large number of timers are generated that are not released, causing a serious memory leak.
Metadata
Metadata
Assignees
Labels
No labels