hangs? Doesn't throw "OutOfMemoryError"? What happens if you start with a 2 GB heap ("-Xms2g -Xmx2g"), can you launch the application?
Interestingly, you are working with the memory available to your instance. Is this a small example? It will start to beat due to the swap, since the amount of memory used is significantly larger than the available physical memory. Perhaps you need a large memory instance.
source share