Skip to content

Memory Leak on org.springframework.boot.actuate.autoconfigure.metrics.AutoConfiguredCompositeMeterRegistry - Spring Boot 2.7.14 #39070

@VitorNilson

Description

@VitorNilson

Issue

I have a Spring boot 2.7.14 + Java 11 application which acts like a proxy (it's a gateway) between client A and target X.

Currently I'm using spring actuator just to do health checks, all the telemetry of the application is done with Opentelemetry + Elastic APM, consequently, I do not need any metrics such as http client requests.

As my application is a proxy, it calls a huge amount of differents targets. The problem is that all requests URIs and URLs are being stored in a HashMap in the application and we are not able to figure out (with a simple configuration) a way to avoid this.

This is the Heap dump:

image

image

As you can see, more then 50% of my heap is being used to store a metric that I do not use, and of course this is a problem. My application ends up running out of memory to handle requests and I experience downtime because of this.

What I have did trying to solve it

I have added the following configuration on my application.yaml to prevent the application adding these metrics on the HashMap (without success):

management:
  metrics:
    enable:
      http:
        server:
          requests: false
        client:
          requests: false

As you could see on the prints, it didn't worked.

I've debugged the code and reached a piece of code that seems like to do the decision if it should or not save the Metric:

image

When I added metrics.enable.http.client.requests=false it stopped adding the metric on the meterMap, so it looked like was ok, but is not.

Expected Behavior

When metrics.enable.http.client.requests=false is added in application.yaml it stops storing metrics on the HashMap meterMap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions