You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Clinton Begin (JIRA)" <ib...@incubator.apache.org> on 2004/11/27 08:31:19 UTC

[jira] Closed: (IBATIS-1) Possible memory leak in LRUCacheController

     [ http://nagoya.apache.org/jira/browse/IBATIS-1?page=history ]
     
Clinton Begin closed IBATIS-1:
------------------------------

     Resolution: Fixed
    Fix Version: 2.0.8

Fixed as suggested

> Possible memory leak in LRUCacheController
> ------------------------------------------
>
>          Key: IBATIS-1
>          URL: http://nagoya.apache.org/jira/browse/IBATIS-1
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Reporter: Clinton Begin
>     Assignee: Clinton Begin
>      Fix For: 2.0.8

>
>  In LRUCacheController, it looks like if you call getObject
> and the key is not in the cache, the key will get left in
> the set, and only half of the cache will be flushed on the
> following putObject command.
> This has the net effect of growing the cache by one for
> every two puts over the cacheSize.
> I think the offending code is below:
> public Object getObject(CacheModel cacheModel,
> Object key) {
> keyList.remove(key);
> keyList.add(key);
> return cache.get(key);
> }
> Consider a fix:
> public Object getObject(CacheModel cacheModel,
> Object key) {
> Object result = cache.get(key);
> keyList.remove(key);
> if (result != null) {
> keyList.add(key);
> }
> return result;
> }
> ---------------------------------------------------
> Date: 2004-11-05 11:15
> Sender: btomasini
> Logged In: YES 
> user_id=595884
> Also consider a simpler approach for an LRU cache.  Less code.
> http://javaalmanac.com/egs/java.util/coll_Cache.html
> Ben

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira