[infinispan-issues] [JBoss JIRA] Issue Comment Edited: (ISPN-868) Running out of memory using Infinispan after adding a small number of entities

Galder Zamarreño (JIRA) jira-events at lists.jboss.org
Wed Jan 12 04:32:49 EST 2011


    [ https://issues.jboss.org/browse/ISPN-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574881#comment-12574881 ] 

Galder Zamarreño edited comment on ISPN-868 at 1/12/11 4:31 AM:
----------------------------------------------------------------

Thanks for the report and the test case. Unfortunately I've imported the test into my IDE and cannot run the tests. See attached errors. Do they ring a bell?

Secondly, I have doubts that you're comparing the same here. The Infinispan configuration that you're using has nothing to do with the default and recommended one (https://github.com/hibernate/hibernate-core/blob/3.6/cache-infinispan/src/main/resources/org/hibernate/cache/infinispan/builder/infinispan-configs.xml). In fact, I think this is key cos the default cache config has no eviction and some of your entities have "pastry" as region name but there's no such cache in the infinispan config, and because your default cache has no eviction/expiration (the ehcache does have eviction/expiration settings in default cache), these caches would grow without limit.

So, let's go back to step one. First of all, based on what I saw in your config, you don't need an infinispan.xml at all. From an Infinispan perspective, here're different options you can use to config Infinispan 2LC:

Option 1. If you remove the region attribute settings of your @Cache annotations, you can use something like this (Box and Bag entities not included):

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.org.foobar.Container.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Container.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Doughnut.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Doughnut.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Muffin.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Muffin.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Carton.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Carton.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Egg.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Egg.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Kiwi.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Kiwi.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Option 2. Still with no regions defined in @Cache, the configuration in Option 1 can be further simplified like this so that all entities have the same eviction/expiration settings:

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.entity.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.entity.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Option 3. If you still wanna keep your @Cache region definitions, based on the region's in the actual code and not the infinispan.xml file, this would look something like this:

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.container.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.container.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.pastry.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.pastry.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.carton.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.carton.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.egg.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.egg.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.kiwi.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.kiwi.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Finally, this is explained in http://community.jboss.org/docs/DOC-14105

      was (Author: galder.zamarreno at jboss.com):
    Thanks for the report and the test case. Unfortunately I've imported the test into my IDE and cannot run the tests. See attached errors. Do they ring a bell?

Secondly, I have doubts that you're comparing the same here. The Infinispan configuration that you're using has nothing to do with the default and recommended one (https://github.com/hibernate/hibernate-core/blob/3.6/cache-infinispan/src/main/resources/org/hibernate/cache/infinispan/builder/infinispan-configs.xml). In fact, I think this is key cos the default cache config has no eviction and some of your entities have "pastry" as region name but there's no such cache in the infinispan config, and because your default cache has no eviction/expiration (the ehcache does have eviction/expiration settings in default cache), these caches would grow without limit.

So, let's go back to step one. First of all, based on what I saw in your config, you don't need an infinispan.xml at all. From an Infinispan perspective, here're different options you can use to config Infinispan 2LC:

Option 1. If you remove the region attribute settings of your @Cache annotations, you can use something like this (Box and Bag entities not included):

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.org.foobar.Container.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Container.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Doughnut.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Doughnut.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Muffin.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Muffin.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Carton.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Carton.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Egg.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Egg.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.org.foobar.Kiwi.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.org.foobar.Kiwi.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Option 2. Still with no regions defined in @Cache, the configuration in Option 1 can be further simplified like this so that all entities have the same eviction/expiration settings:

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.entity.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.entity.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Option 3. If you still wanna keep your @Cache region definitions, based on the region's in the actual code and not the infinispan.xml file, this would look something like this:

<property name="jpaPropertyMap">
  <map>
    <entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.jdbc.batch_size" value="400" />
    <entry key="hibernate.jdbc.fetch_size" value="200" />
    <entry key="hibernate.jdbc.wrap_result_sets" value="true" />
    <entry key="hibernate.generate_statistics" value="true" />
    <!-- 2 is TRANSACTION_READ_COMMITTED -->
    <entry key="hibernate.connection.isolation" value="2" />
				
    <!-- second level cache config for all cache providers -->
    <entry key="hibernate.cache.use_second_level_cache" value="true" />
    <entry key="hibernate.cache.use_query_cache" value="true" />

    <entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
    <entry key="hibernate.cache.infinispan.container.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.container.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.pastry.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.pastry.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.carton.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.carton.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.egg.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.egg.eviction.max_entries" value= "1000"/>
    <entry key="hibernate.cache.infinispan.kiwi.eviction.strategy" value= "LRU" />
    <entry key="hibernate.cache.infinispan.kiwi.eviction.max_entries" value= "1000"/>

    <entry key="hibernate.connection.isolation" value="2" />
    <!-- http://docs.jboss.org/hibernate/core/3.3/reference/en/html/architecture.html#architecture-current-session -->
    <entry key="hibernate.current_session_context_class" value="org.hibernate.context.JTASessionContext" />
    <entry key="hibernate.transaction.manager_lookup_class" value="org.foobar.helper.HibernateTransactionManagerLookup"/>
  </map>
</property>

Finally, all this is in http://community.jboss.org/docs/DOC-14105
  
> Running out of memory using Infinispan after adding a small number of entities
> ------------------------------------------------------------------------------
>
>                 Key: ISPN-868
>                 URL: https://issues.jboss.org/browse/ISPN-868
>             Project: Infinispan
>          Issue Type: Bug
>    Affects Versions: 4.2.0.Final
>         Environment: JBossJTA 4.14.0/Hibernate 3.6.0.Final/Spring 3.0.5
>            Reporter: Tom Waterhouse
>            Assignee: Galder Zamarreño
>             Fix For: 4.2.1.Final
>
>         Attachments: ISPN-868.zip, ispn686-error-galder.txt
>
>
> While running a load test data builder for our application we ran out of memory very quickly.  A simple test case (attached) was created to duplicate the issue.  We found running the simple test case illustrates that Infinispan uses a large amount of heap space.
> As a reference the same test was run using EHCache 2.2.  Memory usage was much lower; we never ran out of heap space.  Note that EHCache was used as a reference only, our goal is to go to production with Infinispan.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the infinispan-issues mailing list