We have two EC2 instances running a web app in an embedded Jetty (version 9.3.8.v20160314). The web app receives requests from mobile app and after some processing, forwards them to a third party server. Peak load is around 10 requests per second. We use Hibernate- 4.2.4.Final, Java 1.8.0_25, hibernate-c3p0 -4.2.1.Final, JAX-RS resteasy-jaxrs-3.0.7.Final with MariaDB as DB.
The issue which is recurring every 7 to 10 days in both the EC2 instances (approximately at the same time) is OOME: Compressed class space. The CPU utilization goes above 70% and both the instances become unresponsive. From application the remote hosts could not be connected, but ping works fine. Restart of the applications resolves the issue.
Server Log: com.sun.xml.ws.server.sei.EndpointMethodHandler invoke SEVERE: Compressed class space java.lang.OutOfMemoryError: Compressed class space
Application Log: com.amazonaws.http.AmazonHttpClient - Unable to execute HTTP request: Broken pipe java.net.SocketException: Broken pipe
com.amazonaws.http.AmazonHttpClient - Unable to execute HTTP request: Remote host closed connection during handshake
The issue did not occur while using Java 1.7 but only when moved to Java 1.8. JVM 1.8 runs with Xmx4000m. Thread dump shows 41% threads waiting on monitor in c3pO thread pool as below: Thread dump trace
Heap dump analysis using Eclipse MAT gets stuck while computing dominator tree, but memory leaks estimate using HPJmeter gives below suspects: HPJmeter Memory leak suspects
Also, Heap size: 243,354,984 Classes: 1,800,395 Objects: 2,592,397
Questions:
1) Why OOME: Compressed class space exception occurring and how to identify leak suspect?
2) Are sockets not garbage collected or they are insufficient for new connections? Same for heap size, should heap size be increased?
3) Is there any connection leak in EntityManager utility using c3pO pool?
4) Do c3pO properties need to be modified to reclaim free sockets? Ideally, c3pO should withstand network outages.
5) Why the issue did not occur in Java 1.7 and occurs in Java 1.8?
Thanks in advance.