My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 203: Memory leak in PropertiesPreferences
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Jul 2009


 
Reported by llppbor...@gmail.com, Jul 2, 2009
I found a memory leak using jmesa on Glassfish v2.1.
After generate a lot of tables along the day the system memory runs out.
The problem is at PropertiesPreferences.java, where the ImputStream is
never closed after the properties load.

Here is the fix:

Public final class PropertiesPreferences implements Preferences {
.
.
.

    public PropertiesPreferences(String preferencesLocation, WebContext
webContext) {
        try {
            InputStream resourceAsStream = getInputStream(JMESA_PROPERTIES,
webContext);
            properties.load(resourceAsStream);
            resourceAsStream.close();
            if (StringUtils.isNotBlank(preferencesLocation)) {
                InputStream input = getInputStream(preferencesLocation,
webContext);
                if (input != null) {
                    properties.load(input);
                    input.close();
                }
            }
        } catch (IOException e) {
            logger.error("Could not load the JMesa preferences.", e);
        }
    }
.
.
.
}
Jul 3, 2009
Project Member #1 jeff.johnston.mn@gmail.com
Thank you! I applied the patch to the trunk and this will go out in the next few weeks.

If you want me to do a custom release for you I can send a custom build to you. Just
send me an email at jeff.johnston.mn@gmail.com.
Status: Fixed
Jul 27, 2009
#2 carlos.c...@gmail.com
A little security patch: close the input streams in a finally block.

Not closing the input streams in a finally block may result in resource leaks (and 
in editing the file being denied) if loading the preferences file fails.
Close_streams_in_finally_block.patch
2.4 KB   View   Download
Jul 28, 2009
Project Member #3 jeff.johnston.mn@gmail.com
Good catch! I will put this in.
Status: Accepted
Jul 29, 2009
Project Member #4 jeff.johnston.mn@gmail.com
It is on the trunk!
Status: Fixed

Powered by Google Project Hosting