opsdis / aci-exporter

A Cisco ACI Prometheus exporter written in Go
https://www.opsdis.com
GNU General Public License v3.0
47 stars 16 forks source link

Fix memory leak if api error happened #23

Closed minefuto closed 1 year ago

minefuto commented 1 year ago

Memory leak occurs per aci-exporter failed to get api. I confirmed it is fixed by this change.

$ go tool pprof -top heap_result
File: aci-exporter
Type: inuse_space
Time: Mar 1, 2023 at 10:08am (JST)
Showing nodes accounting for 5585.60MB, 99.91% of 5590.61MB total
Dropped 51 nodes (cum <= 27.95MB)
      flat  flat%   sum%        cum   cum%
 2542.07MB 45.47% 45.47%  2542.57MB 45.48%  main.Metrics2Prometheus
 1417.89MB 25.36% 70.83%  1418.39MB 25.37%  main.addLabels
 1208.86MB 21.62% 92.46%  1209.36MB 21.63%  main.AciConnection.getByClassQuery
  415.28MB  7.43% 99.88%  1833.68MB 32.80%  main.aciAPI.extractClassQueriesData.func1
    1.50MB 0.027% 99.91%  3044.54MB 54.46%  main.aciAPI.getClassMetrics
thenodon commented 1 year ago

@minefuto thanks for the PR and the findings.