rcrowley / go-metrics

Go port of Coda Hale's Metrics library
Other
3.46k stars 493 forks source link

memory is keeping increase until crash #244

Open vincentzzh33 opened 6 years ago

vincentzzh33 commented 6 years ago

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

shriram1993 commented 5 years ago

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

shriram1993 commented 5 years ago

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.

shriram1993 commented 5 years ago

Any Update on this?

luzhuqun commented 5 years ago

Any Update?

michaelschlies commented 5 years ago

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

omgommt commented 4 years ago

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)

omgommt commented 4 years ago

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)