Fixed
Details
Details
Assignee
Unassigned
UnassignedReporter
Alistair Priest
Alistair PriestComponents
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created May 22, 2006 at 7:50 AM
Updated July 12, 2008 at 1:41 PM
Resolved July 31, 2006 at 1:18 AM
Hi,
Following on from [url=http://forum.hibernate.org/viewtopic.php?t=959404&highlight=softquerycache]my post/url which was causing an ever growing amount of memory in NHibernate when using HQL queries, I have found two bugs in the SysCache implementation. I have written and tested a patch for SysCache which fixes these:
1) When an item is placed into the cache, if it does not already exist it is added with an expiration policy. If the item does exist, it is placed into the cache without an expiration policy - this means that the item lives until the garbage collector decides to remove it. I have modified the Put method so that if the key is already contained in the cache, it is removed and the new item can be inserted with an expiration policy.
2) When an item was being overwritten in the cache (Cache[key]=value) it caused the callback to fire which would delete the _map reference to the key. As the item was then being added into the cache, this meant the _map set of keys would not be synchronised. I've changed this to use cache dependancies:- when the cache is created a root cache node is created which all items in the cache become dependant upon. When the Clear method is called it removes the root cache node, causing all dependant cache items to be removed. This removes the requirement for the Hashtable _map which contained a list of all keys added by the cache instance.
I've attached the unit test and patch for both issues.
Al