Potential memory leak in Jersey2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Potential memory leak in Jersey2

Rakesh Kumar
Hi,
I had recently migrated my REST APIs from Jersey 1 to Jersey 2 (2.22.1 to be exact). The application is running as a spring boot app. The application receives a fairly large amount of traffic. I profiled the application using JMC(Java Mission Control) and noticed large amount of memory consumed by Annotations (getEntityAnnotations()). More details in the jms screenshot:

From the screenshot you can see that 312 Annotation[] objects hold 1.55 GB of memory (~5 MB per array). I had break point in the getEntityAnnotations() method and observed that the Annotation[] contains only 3 annotations (HTTP Method, Path and Consumes). The Annotation objects have only a few fields. I am not able to explain the reason for the large size of the fields. Additionally the size is increasing over time. More details in debugger screenshot:

Has anyone encountered a similar issue?

Additionally from the jms screenshot we can observe that half of the memory is from Arrays.copyOf. This is because the getEntityAnnotations() method in the OutboundMessageContext class clones the entityAnnotations array. This particular implementation has been added in jersey 2.5 as a part of the ticket JERSEY-2072.. Is there a particular reason for this.

I am using Java 1.8.0_60 and spring boot 1.3.2.RELEASE. Please let me know if you need any additional details about the application or the environment

Thanks

Kiran

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Potential memory leak in Jersey2

Bjorn Rohde Jensen
Hi Kiran,

> Hi,
> I had recently migrated my REST APIs from Jersey 1 to Jersey 2 (2.22.1 to
> be exact). The application is running as a spring boot app. The application
> receives a fairly large amount of traffic. I profiled the application using
> JMC(Java Mission Control) and noticed large amount of memory consumed by
> Annotations (getEntityAnnotations()). More details in the jms screenshot:
>
> ​From the screenshot you can see that 312 Annotation[] objects hold 1.55 GB
> of memory (~5 MB per array). I had break point in the
> getEntityAnnotations() method
> and observed that the Annotation[] contains only 3 annotations (HTTP
> Method, Path and Consumes). The Annotation objects have only a few fields.
> I am not able to explain the reason for the large size of the fields.
> Additionally the size is increasing over time. More details in debugger
> screenshot:
>
> ​Has anyone encountered a similar issue?
>

We have observed the same problem with massive metaspace leaks with the
jersey 2 and java 8 combination with several unreleated rest services.
We chose to downgrade to jersey 1, since we viewed the java upgrade as
more important.

> Additionally from the jms screenshot we can observe that half of the memory
> is from Arrays.copyOf. This is because the getEntityAnnotations() method in
> the OutboundMessageContext class clones the entityAnnotations array. This
> particular implementation has been added in jersey 2.5 as a part of the
> ticket JERSEY-2072 <https://java.net/jira/browse/JERSEY-2072>.. Is there a
> particular reason for this.
>
> I am using Java 1.8.0_60 and spring boot 1.3.2.RELEASE. Please let me know
> if you need any additional details about the application or the environment
>
> Thanks
>
> Kiran

Yours sincerely,

Bjorn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Potential memory leak in Jersey2

Rakesh Kumar
Hi Bjorn,
Thanks for the reply. Is there a bug raised for this.

Thanks
Kiran

On Wed, Jun 1, 2016 at 11:47 AM, Bjorn Rohde Jensen <[hidden email]> wrote:
Hi Kiran,

> Hi,
> I had recently migrated my REST APIs from Jersey 1 to Jersey 2 (2.22.1 to
> be exact). The application is running as a spring boot app. The application
> receives a fairly large amount of traffic. I profiled the application using
> JMC(Java Mission Control) and noticed large amount of memory consumed by
> Annotations (getEntityAnnotations()). More details in the jms screenshot:
>
> ​From the screenshot you can see that 312 Annotation[] objects hold 1.55 GB
> of memory (~5 MB per array). I had break point in the
> getEntityAnnotations() method
> and observed that the Annotation[] contains only 3 annotations (HTTP
> Method, Path and Consumes). The Annotation objects have only a few fields.
> I am not able to explain the reason for the large size of the fields.
> Additionally the size is increasing over time. More details in debugger
> screenshot:
>
> ​Has anyone encountered a similar issue?
>

We have observed the same problem with massive metaspace leaks with the
jersey 2 and java 8 combination with several unreleated rest services.
We chose to downgrade to jersey 1, since we viewed the java upgrade as
more important.

> Additionally from the jms screenshot we can observe that half of the memory
> is from Arrays.copyOf. This is because the getEntityAnnotations() method in
> the OutboundMessageContext class clones the entityAnnotations array. This
> particular implementation has been added in jersey 2.5 as a part of the
> ticket JERSEY-2072 <https://java.net/jira/browse/JERSEY-2072>.. Is there a
> particular reason for this.
>
> I am using Java 1.8.0_60 and spring boot 1.3.2.RELEASE. Please let me know
> if you need any additional details about the application or the environment
>
> Thanks
>
> Kiran

Yours sincerely,

Bjorn

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Potential memory leak in Jersey2

Bjorn Rohde Jensen
> Hi Bjorn,
> Thanks for the reply. Is there a bug raised for this.
>

Hi Kiran,

I am not sure, if there is a bug report covering this exact problem, but
i remember finding a couple of entries in the issue tracker, which
seemed to fit the bill.

Fx;

https://java.net/jira/browse/JERSEY-3054

> Thanks
> Kiran
>
> On Wed, Jun 1, 2016 at 11:47 AM, Bjorn Rohde Jensen <[hidden email]>
> wrote:
<snip>

Yours sincerely,

Bjorn

Loading...