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
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
And then using the aforementioned Memory Analyzer.