I'm having a really bad time trying to track down this OutOfMemoryError and I'd really appreciate some help. My application is split into the architecture part and a module which exposes some basic REST WS with database CRUD operations made by Hibernate. The main architecture has the only role of logging and managing properties and configurations (all of this is handled by Spring).
The application isn't doing anything so fancy but still after 2-3 hot redeploy with Tomcat 7 I'm getting an OutOfMemoryError. I've done an Heap dump and opened it with VisualVM and this is what I see:
As you can see, I'm having lots of Strings, char[] and byte[] around. The only class really manipulating this kind of data is the logger which is a servlet-filter only doing this:
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
Map<String, String> requestMap = this
.getTypesafeRequestMap(httpServletRequest);
BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(
httpServletRequest);
BufferedResponseWrapper bufferedResponse = new BufferedResponseWrapper(
httpServletResponse);
final StringBuilder logMessage = new StringBuilder(
"REST Request - ").append("[HTTP METHOD:")
.append(httpServletRequest.getMethod())
.append("] [PATH INFO:")
.append(httpServletRequest.getRequestURI())
.append("] [REQUEST PARAMETERS:").append(requestMap)
.append("] [REQUEST BODY:")
.append(bufferedRequest.getRequestBody())
.append("] [REMOTE ADDRESS:")
.append(httpServletRequest.getRemoteAddr()).append("]");
long startTime = System.currentTimeMillis();
chain.doFilter(bufferedRequest, bufferedResponse);
long elapsed = System.currentTimeMillis() - startTime;
logMessage.append(" [RESPONSE:")
.append(bufferedResponse.getContent())
.append("] [ELAPSED TIME:").append(elapsed).append("ms]");
log.debug(logMessage.toString());
}
If the logger is not the cause of this, may it be due to some Spring/Hibernate/Tomcat/some library that I'm not aware of?
If you need anything else, like Spring configurations, feel free to ask.
Thank you!