Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-4905

HHH-4317 Memory leak in EnumType class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: EAP_EWP 5.1.0_CR1, EAP_EWP 5.1.0_CR2
    • Fix Version/s: EAP_EWP 5.1.1
    • Component/s: Hibernate
    • Labels:
      None
    • Affects:
      Release Notes
    • Release Notes Text:
      Hide
      <classname>org.hibernate.type.EnumType</classname> used a static map to cache the <type>enum</type> values, because getting the value of the <type>enum</type> by reflecting is expensive. However, this implementation had the potential to cause memory leaks in come circumstances, especially when using Hibernate in the application server. This is because the cached objects would never be garbage-collected, so the Map acting as cache kept growing infinitely.

      Instead of using a global <type>enum</type> cache, Hibernate now uses a transient array for each <classname>EnumType</classname> instance to cache the enum values. This improves performance and eliminates the memory leak.
      Show
      <classname>org.hibernate.type.EnumType</classname> used a static map to cache the <type>enum</type> values, because getting the value of the <type>enum</type> by reflecting is expensive. However, this implementation had the potential to cause memory leaks in come circumstances, especially when using Hibernate in the application server. This is because the cached objects would never be garbage-collected, so the Map acting as cache kept growing infinitely. Instead of using a global <type>enum</type> cache, Hibernate now uses a transient array for each <classname>EnumType</classname> instance to cache the enum values. This improves performance and eliminates the memory leak.
    • Release Notes Docs Status:
      Documented as Resolved Issue

      Description

      http://opensource.atlassian.com/projects/hibernate/browse/HHH-4317
      ------------
      Holding enum values in static enumValues map in EnumType class causes memory leaks on application server where hibernate is loaded by application server's common classloader (like for default configuration of JBoss4).
      SoftReference or SessionFactory based caching should be used instead.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                stliu Strong Liu
                Reporter:
                stliu Strong Liu
                Writer:
                Misty Stanley-Jones
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: