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

Metrics objects are not cleaned up when rebuilding context, eventually resulting in OutOfMemoryError #973

Open
mcanalesmayo opened this issue Mar 12, 2024 · 0 comments

Comments

@mcanalesmayo
Copy link

Expected Behavior

If a Micronaut test is annotated like @MicronautTest(rebuildContext = true), I'd expect everything to be cleaned up including the registered metrics objects (when using Micronaut Micrometer integration).

Actual Behaviour

It seems like metrics objects are not cleaned up, while new ones are created for each test every time the context is rebuilt, eventually resulting in java.lang.OutOfMemoryError.

Existing workaround is to disable metrics if they are not needed by the tests, via micronaut.metrics.binders.kafka.enabled or micronaut.metrics.binders.kafka.streams.enabled.

Steps To Reproduce

We have a Kafka Streams project with 70+ tests that require rebuildContext = true due to the use of @Requires and @Property (as documented here). For each test, different Kafka streams are created.

Eventually, it hangs and results in OutOfMemoryError in some application thread (unrelated to Kafka streams). We took a heap dump on out of memory error and analyzed it with VisualVM. We can observe the number of KafkaMetricMeterType object is quite high, which suggests that they are not cleaned up every time context is rebuilt.

Please, see screenshot below.

Screenshot 2024-03-12 at 20 14 50

Environment Information

JDK 21

Example Application

No response

Version

4.3.3

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

1 participant