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

Memory leak (?) #197

Open
ugo-fl opened this issue Jul 5, 2022 · 4 comments
Open

Memory leak (?) #197

ugo-fl opened this issue Jul 5, 2022 · 4 comments

Comments

@ugo-fl
Copy link

ugo-fl commented Jul 5, 2022

Currently using this client (3.0.0) within a JAX-RS API and experiencing a memory leak which causes after a certain time the server to crash.

After adding a @PreDestroy method which calls statsd.stop() the curve is smoothed, but still going up :

image

Without this, it only takes a few hours for our server to freeze.

@vickenty
Copy link
Contributor

vickenty commented Jul 6, 2022

Hi @ugo-fl, thank you for raising the issue, we will try to reproduce it.

Since you mention @PreDestroy, are you creating client instances for each web request? If so, having to call .stop() is expected: the client starts background threads, so an explicit call is needed to stop them when the client instance is no longer needed. At the same time, creating and stopping a client instance is relatively expensive, so I would recommend to have only one global instance per application. The client is thread safe and the same instance can be used to send metric from all resources.

@ugo-fl
Copy link
Author

ugo-fl commented Jul 7, 2022

Hello @vickenty, thank you for your feedback.

I've just tried with a singletonized version of the client, now no metrics are being sent/received and the memory still goes up.
When the whole API is a singleton then I get the metrics properly, but the memory leak is still present.

I think I'm going to quit using the client for the moment and try to post metrics directly instead.

@ugo-fl
Copy link
Author

ugo-fl commented Jul 7, 2022

Wait actually it went up in the first 20 minutes but now after a few hours it seems to have stabilized.
I'll come back at you after some days, but to setup the API as a singleton could be the solution.

@KirilMilanovTide
Copy link

KirilMilanovTide commented Jul 11, 2024

Has anyone observed such issues on version 4.2.0 of the statsD client?

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