You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Reto Bachmann-Gmür <re...@trialox.org> on 2009/01/27 14:13:31 UTC
Memory leak in org.apache.felix.framework.security
Due to a wrong implementation of equals in Permissions.Entry m_cache
gets bigger and bigger. A fix is to replace line 180 of Permissions.java
(in org.apache.felix.framework.security.util) with the following:
if (o instanceof Entry) {
return entry.equals(((Entry)o).get());
} else {
return false;
}
Regards,
Reto
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Memory leak in org.apache.felix.framework.security
Posted by Karl Pauls <ka...@gmail.com>.
Hm, I think I can see the issue. I will have to look into it a bit
more - I will come back to you. Thanks.
regards,
Karl
On Tue, Feb 24, 2009 at 6:21 PM, Reto Bachmann-Gmür
<re...@trialox.org> wrote:
> Hi Karls
>
>
> The still seems to be a memory leak, after running for a while I've
> thousands of live instances of Permissions and of Permissions#Entry. The
> problem seems to be related to the cache-maps in Permissions.
>
> Disabling the static cache with the following:
>
>
> private static final Map m_permissions = new AbstractMap() {
>
> public Set entrySet() {
> return new HashSet();
> }
>
> public Object put(Object key, Object value) {
> return null;
> }
>
>
>
> };
>
> "fixes" the memory leak.
>
> I've not yet understood why the cleaning of the cache with the
> ReferenceQueue isn't working as expected.
>
> One thing I don't understand with m_permissionCache is why addToCache()
> creates a soft-reference with the non-static m_queue as
> ReferenceQueue, but I don't think this is related with the problem as
> the allocations that do not get eligible for garbage-collections are
> instantiated in Permissions.getPermissions().
>
> What seems to be wrong is the m_permissions.get(permissionInfos) in
> Permissions.getPermissions() which should be m_permissions.get(new
> Entry(permissionInfos)), but this odesn't solve the problem of the
> continuosly growing m_permissions.
>
> Another thing I don't understand are why this HashMaps with the
> weak-references as key are used and not WeakHashMap().
>
> Regards,
> reto
>
>
> Karl Pauls said the following on 01/28/2009 01:28 AM:
>> Thanks. Fixed in trunk (as of revision 738319).
>>
>> regards,
>>
>> Karl
>>
>> On Tue, Jan 27, 2009 at 2:13 PM, Reto Bachmann-Gmür
>> <re...@trialox.org> wrote:
>>
>>> Due to a wrong implementation of equals in Permissions.Entry m_cache
>>> gets bigger and bigger. A fix is to replace line 180 of Permissions.java
>>> (in org.apache.felix.framework.security.util) with the following:
>>>
>>> if (o instanceof Entry) {
>>> return entry.equals(((Entry)o).get());
>>> } else {
>>> return false;
>>> }
>>>
>>> Regards,
>>> Reto
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
--
Karl Pauls
karlpauls@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Memory leak in org.apache.felix.framework.security
Posted by Reto Bachmann-Gmür <re...@trialox.org>.
Hi Karls
The still seems to be a memory leak, after running for a while I've
thousands of live instances of Permissions and of Permissions#Entry. The
problem seems to be related to the cache-maps in Permissions.
Disabling the static cache with the following:
private static final Map m_permissions = new AbstractMap() {
public Set entrySet() {
return new HashSet();
}
public Object put(Object key, Object value) {
return null;
}
};
"fixes" the memory leak.
I've not yet understood why the cleaning of the cache with the
ReferenceQueue isn't working as expected.
One thing I don't understand with m_permissionCache is why addToCache()
creates a soft-reference with the non-static m_queue as
ReferenceQueue, but I don't think this is related with the problem as
the allocations that do not get eligible for garbage-collections are
instantiated in Permissions.getPermissions().
What seems to be wrong is the m_permissions.get(permissionInfos) in
Permissions.getPermissions() which should be m_permissions.get(new
Entry(permissionInfos)), but this odesn't solve the problem of the
continuosly growing m_permissions.
Another thing I don't understand are why this HashMaps with the
weak-references as key are used and not WeakHashMap().
Regards,
reto
Karl Pauls said the following on 01/28/2009 01:28 AM:
> Thanks. Fixed in trunk (as of revision 738319).
>
> regards,
>
> Karl
>
> On Tue, Jan 27, 2009 at 2:13 PM, Reto Bachmann-Gmür
> <re...@trialox.org> wrote:
>
>> Due to a wrong implementation of equals in Permissions.Entry m_cache
>> gets bigger and bigger. A fix is to replace line 180 of Permissions.java
>> (in org.apache.felix.framework.security.util) with the following:
>>
>> if (o instanceof Entry) {
>> return entry.equals(((Entry)o).get());
>> } else {
>> return false;
>> }
>>
>> Regards,
>> Reto
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Memory leak in org.apache.felix.framework.security
Posted by Karl Pauls <ka...@gmail.com>.
Thanks. Fixed in trunk (as of revision 738319).
regards,
Karl
On Tue, Jan 27, 2009 at 2:13 PM, Reto Bachmann-Gmür
<re...@trialox.org> wrote:
> Due to a wrong implementation of equals in Permissions.Entry m_cache
> gets bigger and bigger. A fix is to replace line 180 of Permissions.java
> (in org.apache.felix.framework.security.util) with the following:
>
> if (o instanceof Entry) {
> return entry.equals(((Entry)o).get());
> } else {
> return false;
> }
>
> Regards,
> Reto
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
--
Karl Pauls
karlpauls@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org