You can tune your Java Application Runtime settings:
maximize heap size to high value with -Xmx
say 500M
tune -XX:MaxHeapFreeRatio
and -XX:MinHeapFreeRatio
to make sure that the application will not becomes irresponsive when consuming lot of memory when the heap reduces.