We are seeing Hibernate store a lot of information in the Session (first level cache) and eventually see OutOfMemory exceptions.

Solution Verified - Updated -

Issue

  • The application works fine for say 4 days at a stretch and then the JVM crashes with a OutofMemory error.
  • We see a lot of memory being used by org/hibernate/
  • We analyze this heap dump and we detect the high usage of org.hibernate.impl.SessionFactoryObjectFactory class (83% usage of memory).

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 4
    • 5
    • 6
  • Hibernate
    • 3.3.x
  • Heap analyzer shows:

    692,139,472 (32%) [88] 14 org/hibernate/engine/StatefulPersistenceContext 0x5ede0268
     659,080,192 (31%) [24] 3 org/hibernate/util/IdentityMap 0x5ede0678
     659,080,144 (31%) [32] 3 org/apache/commons/collections/SequencedHashMap 0x5ede0690
     24 (0%) [24] 1 array of java/util/Map$Entry 0x5ede0700
     96 (0%) [32] 22 class org/hibernate/util/IdentityMap 0x37fb9238
    27,924,656 (1%) [48] 2 java/util/HashMap 0x5ede02c0
     27,924,608 (1%) [994,528] 248,627 array of java/util/HashMap$Entry 0x87bc1c38
      640 (0%) [32] 4 java/util/HashMap$Entry 0x9a1a2708
      560 (0%) [32] 4 java/util/HashMap$Entry 0x9b0365e8
      560 (0%) [32] 4 java/util/HashMap$Entry 0xb19044c8 
    

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.