Scorpion's Corner

Tuesday Sep 16, 2008

Common Reasons for Out Of Memory Errors

Out Of Memory error can happen due to following reasons:



  • Garbage Collection Issues

  • Orphaned Class loaders

    • Thread context classloader

    • new Thread()

    • Dangling thread



  • Classes with following references

    • static variables

    • SQL Driver

    • Commons logging

    • java.util.logging.Level

    • Bean util

      • Details






etc..


We can analyze the problem(s) associated with such errors at application level by having GC details and/or heap dump



  • -verbose:gc with -XX:+PrintGCDetails for observing GC model for tuning or altering suitable GC for the application

  • -XX:+HeapDumpOnOutOfMemoryError

  • -Xrunhprof:heap=dump,format=b

  • jmap -dump:format=b,file=heap.bin <pid>


Analyze heap dump using Jhat



  • jhat -J-mx1024m heap.bin

  • http://localhost:7000

  • Using built-in or custom queries to narrow down leak suspects

  • Identify an object or class in the application

  • List reference chains

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed