We are using Java 8 Spring Boot 2 for our micro-service app. Running a load test locally noticed the heap consuming memory but never releasing back. I am running the app with G1 garbage collector and also did a manual GC from JVisualVM, but still the allocated memory never gets released.
I took the heap dump and analysed it, and I can clearly see the large byte array created by System Class Loader listed as leak suspect. I see the byte array instance holds my HTTP request to endpoint "/test". But the load test already completed and threads went back down to where they were before running load test.
Not sure why byte array loaded by system class loader contains all these elements and taking all this heap for no reason.
/test endpoint is the only method in a @RestController class
@RequestMapping(value = "/test", method = RequestMethod.GET)
@CrossOrigin(origins = "*")
public void test() {
logger.info("Testing1...");
}
Below are the Spring Boot application.properties related to server:
server.port=8090
server.tomcat.max-threads=200
server.tomcat.accept-count=100
server.tomcat.min-spare-threads=20
server.error.whitelabel.enabled=false
server.max-http-header-size=2097152