incubator-s4-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "qiu zhan bo (JIRA)" <j...@apache.org>
Subject [jira] [Created] (S4-52) Avoid memory leak
Date Fri, 01 Jun 2012 03:19:26 GMT
qiu zhan bo created S4-52:
-----------------------------

             Summary: Avoid memory leak
                 Key: S4-52
                 URL: https://issues.apache.org/jira/browse/S4-52
             Project: Apache S4
          Issue Type: Improvement
    Affects Versions: 0.4, 0.3
            Reporter: qiu zhan bo
             Fix For: 0.4, 0.3


Persister#cleanOutGarbage will clean expired object,but there may be some risk which lead
to memory leak .it should notify the Object to clean resource.
I have improved the the method as follows:

    public int cleanOutGarbage()
    {
        int count = 0;
        for (Enumeration en = cache.keys(); en.hasMoreElements();)
        {
            String key = (String)en.nextElement();
            CacheEntry ce = cache.get(key);
            if (ce != null && ce.isExpired())
            {
                count++;
                Object obj = ce.value;
                if (obj instanceof Releasable)
                {
                    ((Releasable)obj).release();
                }
                cache.remove(key);
            }
        }
        return count;
    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message