5

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:

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. More details in debugger screenshot:

debugger screenshot

Has anyone encountered a similar issues?

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.

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

zapl
  • 63,179
  • 10
  • 123
  • 154
Kiran
  • 51
  • 3

0 Answers0