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