rcrowley / go-metrics

Go port of Coda Hale's Metrics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

memory is keeping increase until crash

vincentzzh33 opened this issue · comments

newStandardMeter newEWMA these two memory is keeping increase until crash when i using sarama as httpserver to receive kafka request

Yes!! We are also facing memory leak in newStandardMeter & newEWMA. Attached pprof graph screenshot for reference. Please help.
screenshot-localhost-8081-2019 05 01-12-14-14

Yes!! We are also facing memory leak in newStandardMeter & newEWMA. Attached pprof graph screenshot for reference. Please help.
screenshot-localhost-8081-2019 05 01-12-14-14

If you need more info, I can provide.

Any Update on this?

Any Update?

Is anyone that is running into this registering their Meters with the registry in go-metrics? I just refactored registry to use a sync.Map instead of a mutex managed map and removing its switch() for what to allow to register and my memory leaks have completely stopped. In my case it kept calling NewStandardMeter or NewEWMA because the metrics didn't exist in the registry already

@luzhuqun @shriram1993 @vincentzzh33

Identified the issue:
Its happening because we are passing NewMetric object with every metric log. Instead it should be function, which will be called when new Metric object is required.

Before:
.RcRegistry.GetOrRegister(timerName, rcmetric.NewTimer()).(rcmetric.Timer)

After: (Correct)
.RcRegistry.GetOrRegister(timerName, rcmetric.NewTimer).(rcmetric.Timer)

Any Update on this?

Identified the issue:
Its happening because we are passing NewMetric object with every metric log. Instead it should be function, which will be called when new Metric object is required.

Before:
.RcRegistry.GetOrRegister(timerName, rcmetric.NewTimer()).(rcmetric.Timer)

After: (Correct)
.RcRegistry.GetOrRegister(timerName, rcmetric.NewTimer).(rcmetric.Timer)