For example, add the following test:
Typical output will look like the following:
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid14838.hprof ...
Heap dump file created [1515333529 bytes in 21.641 secs]
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 85.68 sec <<< FAILURE!
The heap dump (this is a huge binary file) will be named java_pid<process_pid>.hprof, and will be created by JVM in the current directory of the test run process (e.g. .../hadoop-common/hadoop-hdfs-project/hadoop-hdfs/ in my case). The heap dump can be opened and investigated with almost any profiler, including NetBeans.
Note, however, that the "-XX" ( http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html ) are HostSpot options, they may not work on other JVM implementations.
But, afaik, most of the testing is done on Orecle's JVMs 1.6.0_XX, so the option will work and will be helpful in case of OOME problems.
As experience shows, if there are no OOMEs, this option does not appear to introduce any problems or performance penalties.