<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
We could definitely try that. I'm not sure what happens internally when an OOM is raised by the VM. <BR> <BR>
> Date: Fri, 14 Jan 2011 09:40:37 +0100<BR>> From: bban@redhat.com<BR>> To: infinispan-dev@lists.jboss.org<BR>> Subject: Re: [infinispan-dev] ISPN-863 - Thoughts / Questions<BR>> <BR>> Excellent, memory based eviction is very important ! This has been on <BR>> the todo list for years !<BR>> <BR>> One thing you might want to think about is - *in addition* to what you <BR>> say below - whether you want to add an OOME handler, which evits on OOME <BR>> caused by putXXX() methods.<BR>> <BR>> For example, you could wrap all methods which add to the map to catch <BR>> OOMEs. When this is the case, kick off the eviction handler to evict <BR>> elements immediately. Kind of like a second line of defense against OOMEs...<BR>> <BR>> <BR>> WDYT ?<BR>> <BR>> <BR>> <BR>> On 1/14/11 4:22 AM, david marion wrote:<BR>> ><BR>> > I have been looking at the code and think I have a starting point on the design. Remember, the goal here is to be able to create a cache that uses expiration but has no defined cache size limit. Reading through the code, if ‘-1’ is specified for the eviction maxEntries, then a ConcurrentHashMap is created and used as the data container and no eviction is performed. Otherwise a BoundedConcurrentHashMap is created and used as the data container and eviction is performed according to the specified strategy.<BR>> ><BR>> > Eviction currently appears to happen in two different ways:<BR>> ><BR>> > 1. If an entry is expired, then it can be evicted.<BR>> > 2. If the number of entries in a segment of the cache contains more entries than “allowed” by the configuration.<BR>> ><BR>> > Here are the modifications that I think need to be made. I have not made any code mods yet, so I don’t know for sure if this will work. Definitely looking for feedback.<BR>> ><BR>> ><BR>> > Modify configuration in some way so that the following can be specified:<BR>> ><BR>> > The percentage value of used JVM memory (i.e. 95) at which entries should be evicted to try and avoid an OOM error.<BR>> > The number of items that should be evicted when memory reaches this threshold<BR>> > Modify LRU and LIRS Eviction class so that the accessQueue member can be accessed by the new Eviction class so that two access queues don’t have to be maintained.<BR>> > Create a new Eviction class, a subclass of LIRS, where the accessQueue is used from the Eviction strategy the user specifies and the for loop in the execute method is exited when the evicted set equals value from 1.b above.<BR>> > Modify DataContainerFactory.construct() to call DefaultDataContainer.boundedDataContainer() regardless of eviction policy. This will always create a BoundedConcurrentHashMap<BR>> > Create an instance of the new Eviction class in each segment.<BR>> > Modify BoundedConcurrentHashMap.Segment put and replace methods such that when new values are going to be put into the Segment, the memory usage is checked and the execute method is called on the new Eviction class.<BR>> ><BR>> > Questions:<BR>> ><BR>> ><BR>> > What are the implications of using a BoundedConcurrentHashMap instead of a ConcurrentHashMap when maxEntries is set to -1?<BR>> ><BR>> > Thoughts<BR>> ><BR>> ><BR>> > This will not guarantee that an OOM error does not occur. It will attempt to guard against an OOM caused by putting new values into the cache. This will probably be more effective when the cache is being used in client/server mode, and less effective when used in embedded mode as to other code running in the JVM.<BR>> <BR>> -- <BR>> Bela Ban<BR>> Lead JGroups / Clustering Team<BR>> JBoss<BR>> _______________________________________________<BR>> infinispan-dev mailing list<BR>> infinispan-dev@lists.jboss.org<BR>> https://lists.jboss.org/mailman/listinfo/infinispan-dev<BR>                                            </body>
</html>