I have an application that is working fine on my local machine (windows 7 with -Xmx256m) but keeps getting heap space error upon the first request on remote server (linux 3.0.76-0.11-default with -Xmx2g). Heap dump looks like this and goes to infinity:
My code is not recursive and is not memory intensive, any idea what can cause this type of behaviour?
In my exact case I was getting a FileNotFoundException from a class which had a field like: static final template = new ClassPathResource(..)
So I tried to minimally recreate it here: https://gist.github.com/kramer/c15ada4fca127d251506 I can't see if this one gets heap space error too (because it does not print that) but it never responds and goes into an infinite loop causing serious cpu&memory spike upon receiving the request.