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

    • Bug
    • Resolution: Done
    • Major
    • EAP_EWP 5.1.1
    • EAP_EWP 5.1.0_CR1, EAP_EWP 5.1.0_CR2
    • Hibernate
    • None
    • Release Notes
    • 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.
    • 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.

      Attachments

        Activity

          People

            shaozliu Strong Liu(刘少壮) (Inactive)
            shaozliu Strong Liu(刘少壮) (Inactive)
            Misty Stanley-Jones Misty Stanley-Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: