Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to stop meter? #163

Closed
let4be opened this issue Mar 28, 2016 · 5 comments
Closed

A way to stop meter? #163

let4be opened this issue Mar 28, 2016 · 5 comments

Comments

@let4be
Copy link

let4be commented Mar 28, 2016

I checked the code and it seems it's totally impossible to stop a meter
i.e. using lots of disposable meters gonna end up in a massive resource waste

@ariens-shopify
Copy link

@let4be can you provide more information on this? I'm tracking down a memory leak where I would have thought calling registry.UnregisterAll() freed the resources, but that doesn't appear to be the case.

@mihasya
Copy link
Collaborator

mihasya commented Feb 17, 2017

Interesting. I can say with SOME confidence that "ephemeral meters" is likely a thing that wasn't considered/designed for.

@ariens-shopify
Copy link

I'm using go-metrics as I consume and parse events from Kafka. Every "event" contains a name and a scope. I then call metrics.GetOrRegisterMeter("counter-<scope>-<name>, registry).Mark(1) each time I consume an event. Every second I iterate over metrics, looking for meters, then punt the counters somewhere downstream and then call registrry.UnregisterAll().

This is leaking for me:

Fetching profile from http://localhost:8888/debug/pprof/heap
Saved profile in /Users/davidariens/pprof/pprof.localhost:8888.inuse_objects.inuse_space.086.pb.gz
Entering interactive mode (type "help" for commands)
(pprof) top10
13326.09kB of 13326.09kB total (  100%)
Dropped 67 nodes (cum <= 66.63kB)
Showing top 10 nodes out of 29 (cum >= 1541.07kB)
      flat  flat%   sum%        cum   cum%
10760.92kB 80.75% 80.75% 10760.92kB 80.75%  reflect.Value.cal

That reflect.Value.cal grows until out-of-memory.

Is there any work-around here or should I drop go-metrics and adopt some locking string/int map based counter on my own?

@let4be
Copy link
Author

let4be commented Feb 17, 2017

it was a while ago I was looking for this, don't have all details right now
Afaik it's not possible to stop meter ar all, i.e. free all associated with it resources

@let4be let4be closed this as completed Feb 17, 2017
@let4be let4be reopened this Feb 17, 2017
@let4be
Copy link
Author

let4be commented Feb 17, 2017

suspect
https://github.com/rcrowley/go-metrics/blob/master/meter.go#L37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants