I am a newbie at performance tuning applications and figuring out the workings of GC so probably asking the same question a millionth time!
The problem is that 2 - 3 wee
Somewhere your code is creating temporary objects in an memory- less environment.
Please look at your code (HibernateCommentaryDao.java)
it is something with n+1 fetch
Excessive GC Time and OutOfMemoryError
The parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line
Eclipse features a great tool called Memory Analyzer. It can analyze exactly those heap dumps you generate on OOM. It draws pretty good charts to help you narrow where the bulk of your memory consumption is - your app, jboss, other parts of your setup - down to a very fine level.
If you paste its output here we could continue to investigate your problem.
Running with 4GB RAM and using -Xmx1024m
(maximum amount of java heap 1024M) might not be intentional.
On the other hand, it looks to me your query is returning too many results either because of the joins or using null
limit, which turns into an oversized list.
You could start by taking a heap snapshot in the middle of GCs with
# jmap -dump:format=b,file=dump.hprof <pid>
And then using the aforementioned Memory Analyzer.