4 Replies Latest reply on Jan 3, 2011 2:07 PM by dlmarion

    Please clarify eviction rules

    dlmarion

      I was under some assumptions about eviction based on some of the documentation that I read. I believe these are false based on the testing I have done and looking through the source code, but just want some clarification please....

       

      BAD ASSUMPTIONS

      -------------------------------

      1. Eviction takes into account the amount of free memory in the JVM and starts evicting entries when some threshold has been reached.

      2. Eviction will occur even if you specify -1 in the configuration file for maxEntries.

       

      It appears that a cache cannot be created where I want to create a cache (with some unknown up front number of entries) and use eviction to save me from OOM errors. Further, it only appears that entries that have been expired are evicted. Non-expired entries are not evicted based.

       

      Question 1: Should I enter an enhancement request where JVM free memory is taken into account to begin evicting entries from the cache? Or is this already on the roadmap?

       

      Question 2: Related to eviction and a cache store, I did some testing and it does not appear that entries in the cache (when passivation is true) are flushed to the cache store when the cache is being shutdown. Please confirm as I might enter a 2nd enhancement request for this...

       

      Thanks,

        • 1. Re: Please clarify eviction rules
          vblagojevic

          Thanks for your feedback. I clarified some points http://community.jboss.org/wiki/Eviction

          To reiterate your specific case. Both were bad assumptions. The memory enhancement is on a roadmap. If I recall correctly this feature is not easy to implement in an efficient way. Both immortal and mortal entries are target of eviction in 4.2. Previsously it was not the case. See eviction wiki for clarification. For question 2, if an entry is expired it will not be persisted at all. Only non-expired evicted entries should be persisted in your use case.

           

          Regards,

          Vladimir

          1 of 1 people found this helpful
          • 2. Re: Please clarify eviction rules
            dlmarion

            Thanks for the response. Just to clarify, non-expired entries in the cache are persisted to the cache store during a shutdown?

            • 3. Re: Please clarify eviction rules
              vblagojevic

              I don't think there is a special treatment of non-expired entries during shutdown. If you have a backing store your non-expired entries will be there, if you do not have the store then the entries are gone once cache is shutdown.

              1 of 1 people found this helpful
              • 4. Re: Please clarify eviction rules
                dlmarion

                Based on the passivation documentation, when passivation is true, then data in memory is not stored in the cache store. When the cache is shut down and passivation is true, then the data in the cache is lost? I guess I could loop through the keys in the local cache (Cache.keySet()) and call evict for each one before I shutdown the cache......