kjkoster
13-12-2008, 20:48
Dear All,
I have just found and fixed a problem with a Hibernate that I thought I should share.
I had configured an application server with Hibernate to use Ehcache (http://ehcache.sourceforge.net/) as its second level cache. To enable caching I had annotated each entity class with the appropriate @Cache annotation (http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#d0e2911). That worked fine, until I decided to remove Ehcache. My application started leaking memory like carrying tea in a sieve.
As it turned out, I had left the @Cache annotations in. Apparantly the HashtableCacheProvider (http://www.hibernate.org/hib_docs/reference/en/html/performance-cache.html) does not release objects at all. Not even after a while. I guess that answers my question why using HashtableCacheProvider in production is bad. :-)
At any rate, I removed the annotations and now everything is back to normal.
Kees Jan
PS. Why remove Ehcache? I had to move to a new version of Ehcache and that brought in so many extra dependencies that I decided to cull it. I didn't want a fourth complete logging framework (http://www.slf4j.org/). Too much bloat. Plus, it makes no noticeable difference in performance anyway. It is not even worth the bloat.
I have just found and fixed a problem with a Hibernate that I thought I should share.
I had configured an application server with Hibernate to use Ehcache (http://ehcache.sourceforge.net/) as its second level cache. To enable caching I had annotated each entity class with the appropriate @Cache annotation (http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#d0e2911). That worked fine, until I decided to remove Ehcache. My application started leaking memory like carrying tea in a sieve.
As it turned out, I had left the @Cache annotations in. Apparantly the HashtableCacheProvider (http://www.hibernate.org/hib_docs/reference/en/html/performance-cache.html) does not release objects at all. Not even after a while. I guess that answers my question why using HashtableCacheProvider in production is bad. :-)
At any rate, I removed the annotations and now everything is back to normal.
Kees Jan
PS. Why remove Ehcache? I had to move to a new version of Ehcache and that brought in so many extra dependencies that I decided to cull it. I didn't want a fourth complete logging framework (http://www.slf4j.org/). Too much bloat. Plus, it makes no noticeable difference in performance anyway. It is not even worth the bloat.