I'm developing a Java Spring - Hibernate web app that runs on Tomcat. Due to the app nature I'm experiencing memory/heap issues I never had before on other apps I developed. My app is a kind of analysis web tool that manages huge amounts of data that most times end up plotted in the presentation layer using Highcharts (JavaScript library for web charts, reference here). When I started to test it on Tomcat for the first time it crashed after the second request, and since then I've been tracking the memory usage. I'm not an expert on Tomcat but I believe the problem could be around the garbage collector. NetBeans 8.1 brings a memory profiler that shows the following when running on my app:
As you can see the amount of memory consumed is really high, considering it deals with one user. You can clearly see the increase in memory every time I make a request. Once the request finishes and the page is laoded with all the charts the memory used drops a little bit, but it never goes down close to 0. What's more is that after every request the memory drops a higher point, making it unsustainable in the long term. As you can see in the following Firebug screenshot the amount of data sent to the browser through ajax calls is not that huge:
It took 4,5 seconds to send 1,7 MB from the server, involving database accesses and other domain operations. As you can see in Firebug there are several ajax calls, belonging each of them to a Highcharts chart. I believe the garbage collector is not working properly, but I'm not sure. All JVM and Tomcat configurations are the default. What do you think?
Edit: I've checked all my database accesses and I'm sure connections are handled appropiately. Regarding session data, there is not much data stored and it is over-written on each request (my app works as a report application, so all session data for each report execution is overwritten on the next request).