harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martijn Brinkers (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HARMONY-6683) Using a java.security.KeyStore results in a memory leak
Date Wed, 30 Mar 2011 13:51:05 GMT
Using a java.security.KeyStore results in a memory leak
-------------------------------------------------------

                 Key: HARMONY-6683
                 URL: https://issues.apache.org/jira/browse/HARMONY-6683
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Martijn Brinkers
            Priority: Critical


Using a java.security.KeyStore results in a memory leak. The last created instance of KeyStore
cannot be garbage collected because it is referenced from org.apache.harmony.security.fortress.Engine.

If a new KeyStore instance is created, java.security.KeyStore uses a static Engine instance
to create the instance of the class that implements KeyStoreSpi. The reference to this instance
is stored in Engine.spi. With the spi reference a new KeyStore instance is created:

new KeyStore((KeyStoreSpi) engine.spi, engine.provider, type);

The engine.spi value is not set to null after the KeyStore is creayed and because Engine is
static, the reference to the KeyStoreSpi instance from Engine keeps the KeyStoreSpi instance
from being garbage collected. Only if a new KeyStore instance is created will the previous
KeyStore be garbage collected. 

This is problemetic in cases when the last loaded KeyStoreSpi instance is large (for example
a PFX file containing a large number of certificates and keys).

I temporary workaround is to create a new empty KeyStore instance after a large KeyStore was
created because now only the small KeyStore gets locked in memory and not the large one.

Martijn Brinkers

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message