You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Ivan A. Veselovsky (JIRA)" <ji...@apache.org> on 2012/10/01 19:29:07 UTC

[jira] [Commented] (HADOOP-8851) Use -XX:+HeapDumpOnOutOfMemoryError JVM option in the forked tests

    [ https://issues.apache.org/jira/browse/HADOOP-8851?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466979#comment-13466979 ] 

Ivan A. Veselovsky commented on HADOOP-8851:
--------------------------------------------

For example, add the following test:

  /**
   * Test to OOME: with the -XX:+HeapDumpOnOutOfMemoryError option the mem dump should be created by the JVM.   
   * @throws Exception
   */
  public void testOOME() throws Exception {
    final List<Object> list = new LinkedList<Object>();
    while (true) {
      Object placeHolder = new HashMap<Object,Object>();
      list.add(placeHolder);
    }
  }

Typical output will look like the following:
-----
Running org.apache.hadoop.fs.permission.TestStickyBit
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.
                
> Use -XX:+HeapDumpOnOutOfMemoryError JVM option in the forked tests
> ------------------------------------------------------------------
>
>                 Key: HADOOP-8851
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8851
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Ivan A. Veselovsky
>            Assignee: Ivan A. Veselovsky
>            Priority: Minor
>         Attachments: HADOOP-8851-vs-trunk.patch
>
>
> This can help to reveal the cause of issue in the event of OOME in tests.
> Suggested patch attached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira