You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by "Susi Berrington (JIRA)" <ji...@apache.org> on 2008/07/15 20:35:31 UTC

[jira] Created: (TRB-70) Memory leak with page auto-refreshing over several days

Memory leak with page auto-refreshing over several days
-------------------------------------------------------

                 Key: TRB-70
                 URL: https://issues.apache.org/jira/browse/TRB-70
             Project: Turbine
          Issue Type: Bug
          Components: Turbine 2.3
    Affects Versions: Core 2.3.3
         Environment: Linux OS running turbine 2.3.3 & tomcat
            Reporter: Susi Berrington


We have been aware of a memory leak in our system for several years.  After other alterations to our code base it finally reached a stage where we could get an OutOfMemoryError in a couple of days.
So after spending days trying to find a memory leak in our system I finally pinpointed a leak.

http://svn.apache.org/repos/asf/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/services/assemblerbroker/util/java/JavaBaseFactory.java
This class has a hashmap called classCache which uses className (a StringBuffer) as a key.
You cannot use StringBuffer as a key in a hashmap as it does not override Object's hashCode() method.
I attached a debugger and saw the number of items in this map incrementing even though I was returning to a page which was already in the map.

One potential fix is just to call toString() on className when putting it into the classCache.  However as you are only concatenating 5 items className could be changed to a String as follows:
String className = it.next() + "." + packageName + "." + name;
This is less code and also removes the need for the toString() method on subsequent uses of the className.

Patch:

85,91c85
<                 StringBuffer className = new StringBuffer();
< 
<                 className.append(it.next());
<                 className.append('.');
<                 className.append(packageName);
<                 className.append('.');
<                 className.append(name);
---
>                 String className = it.next() + "." + packageName + "." + name;
100c94
<                         servClass = Class.forName(className.toString());
---
>                         servClass = Class.forName(className);


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRB-70) Memory leak with page auto-refreshing over several days

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TRB-70?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613983#action_12613983 ] 

Thomas Vandahl commented on TRB-70:
-----------------------------------

Thanks for bringing this to our attention. Although I beg to differ on the code amount issue, I guess we should fix this immediately.

> Memory leak with page auto-refreshing over several days
> -------------------------------------------------------
>
>                 Key: TRB-70
>                 URL: https://issues.apache.org/jira/browse/TRB-70
>             Project: Turbine
>          Issue Type: Bug
>          Components: Turbine 2.3
>    Affects Versions: Core 2.3.3
>         Environment: Linux OS running turbine 2.3.3 & tomcat
>            Reporter: Susi Berrington
>            Assignee: Thomas Vandahl
>
> We have been aware of a memory leak in our system for several years.  After other alterations to our code base it finally reached a stage where we could get an OutOfMemoryError in a couple of days.
> So after spending days trying to find a memory leak in our system I finally pinpointed a leak.
> http://svn.apache.org/repos/asf/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/services/assemblerbroker/util/java/JavaBaseFactory.java
> This class has a hashmap called classCache which uses className (a StringBuffer) as a key.
> You cannot use StringBuffer as a key in a hashmap as it does not override Object's hashCode() method.
> I attached a debugger and saw the number of items in this map incrementing even though I was returning to a page which was already in the map.
> One potential fix is just to call toString() on className when putting it into the classCache.  However as you are only concatenating 5 items className could be changed to a String as follows:
> String className = it.next() + "." + packageName + "." + name;
> This is less code and also removes the need for the toString() method on subsequent uses of the className.
> Patch:
> 85,91c85
> <                 StringBuffer className = new StringBuffer();
> < 
> <                 className.append(it.next());
> <                 className.append('.');
> <                 className.append(packageName);
> <                 className.append('.');
> <                 className.append(name);
> ---
> >                 String className = it.next() + "." + packageName + "." + name;
> 100c94
> <                         servClass = Class.forName(className.toString());
> ---
> >                         servClass = Class.forName(className);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (TRB-70) Memory leak with page auto-refreshing over several days

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TRB-70?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Vandahl reassigned TRB-70:
---------------------------------

    Assignee: Thomas Vandahl

> Memory leak with page auto-refreshing over several days
> -------------------------------------------------------
>
>                 Key: TRB-70
>                 URL: https://issues.apache.org/jira/browse/TRB-70
>             Project: Turbine
>          Issue Type: Bug
>          Components: Turbine 2.3
>    Affects Versions: Core 2.3.3
>         Environment: Linux OS running turbine 2.3.3 & tomcat
>            Reporter: Susi Berrington
>            Assignee: Thomas Vandahl
>
> We have been aware of a memory leak in our system for several years.  After other alterations to our code base it finally reached a stage where we could get an OutOfMemoryError in a couple of days.
> So after spending days trying to find a memory leak in our system I finally pinpointed a leak.
> http://svn.apache.org/repos/asf/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/services/assemblerbroker/util/java/JavaBaseFactory.java
> This class has a hashmap called classCache which uses className (a StringBuffer) as a key.
> You cannot use StringBuffer as a key in a hashmap as it does not override Object's hashCode() method.
> I attached a debugger and saw the number of items in this map incrementing even though I was returning to a page which was already in the map.
> One potential fix is just to call toString() on className when putting it into the classCache.  However as you are only concatenating 5 items className could be changed to a String as follows:
> String className = it.next() + "." + packageName + "." + name;
> This is less code and also removes the need for the toString() method on subsequent uses of the className.
> Patch:
> 85,91c85
> <                 StringBuffer className = new StringBuffer();
> < 
> <                 className.append(it.next());
> <                 className.append('.');
> <                 className.append(packageName);
> <                 className.append('.');
> <                 className.append(name);
> ---
> >                 String className = it.next() + "." + packageName + "." + name;
> 100c94
> <                         servClass = Class.forName(className.toString());
> ---
> >                         servClass = Class.forName(className);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (TRB-70) Memory leak with page auto-refreshing over several days

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TRB-70?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Vandahl closed TRB-70.
-----------------------------


Fix is in 2.3.3-release

> Memory leak with page auto-refreshing over several days
> -------------------------------------------------------
>
>                 Key: TRB-70
>                 URL: https://issues.apache.org/jira/browse/TRB-70
>             Project: Turbine
>          Issue Type: Bug
>          Components: Turbine 2.3
>    Affects Versions: Core 2.3.3
>         Environment: Linux OS running turbine 2.3.3 & tomcat
>            Reporter: Susi Berrington
>            Assignee: Thomas Vandahl
>             Fix For: Core 2.3.3
>
>
> We have been aware of a memory leak in our system for several years.  After other alterations to our code base it finally reached a stage where we could get an OutOfMemoryError in a couple of days.
> So after spending days trying to find a memory leak in our system I finally pinpointed a leak.
> http://svn.apache.org/repos/asf/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/services/assemblerbroker/util/java/JavaBaseFactory.java
> This class has a hashmap called classCache which uses className (a StringBuffer) as a key.
> You cannot use StringBuffer as a key in a hashmap as it does not override Object's hashCode() method.
> I attached a debugger and saw the number of items in this map incrementing even though I was returning to a page which was already in the map.
> One potential fix is just to call toString() on className when putting it into the classCache.  However as you are only concatenating 5 items className could be changed to a String as follows:
> String className = it.next() + "." + packageName + "." + name;
> This is less code and also removes the need for the toString() method on subsequent uses of the className.
> Patch:
> 85,91c85
> <                 StringBuffer className = new StringBuffer();
> < 
> <                 className.append(it.next());
> <                 className.append('.');
> <                 className.append(packageName);
> <                 className.append('.');
> <                 className.append(name);
> ---
> >                 String className = it.next() + "." + packageName + "." + name;
> 100c94
> <                         servClass = Class.forName(className.toString());
> ---
> >                         servClass = Class.forName(className);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (TRB-70) Memory leak with page auto-refreshing over several days

Posted by "Thomas Vandahl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TRB-70?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Vandahl resolved TRB-70.
-------------------------------

       Resolution: Fixed
    Fix Version/s: Core 2.3.3

Fixed in SVN.

> Memory leak with page auto-refreshing over several days
> -------------------------------------------------------
>
>                 Key: TRB-70
>                 URL: https://issues.apache.org/jira/browse/TRB-70
>             Project: Turbine
>          Issue Type: Bug
>          Components: Turbine 2.3
>    Affects Versions: Core 2.3.3
>         Environment: Linux OS running turbine 2.3.3 & tomcat
>            Reporter: Susi Berrington
>            Assignee: Thomas Vandahl
>             Fix For: Core 2.3.3
>
>
> We have been aware of a memory leak in our system for several years.  After other alterations to our code base it finally reached a stage where we could get an OutOfMemoryError in a couple of days.
> So after spending days trying to find a memory leak in our system I finally pinpointed a leak.
> http://svn.apache.org/repos/asf/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/services/assemblerbroker/util/java/JavaBaseFactory.java
> This class has a hashmap called classCache which uses className (a StringBuffer) as a key.
> You cannot use StringBuffer as a key in a hashmap as it does not override Object's hashCode() method.
> I attached a debugger and saw the number of items in this map incrementing even though I was returning to a page which was already in the map.
> One potential fix is just to call toString() on className when putting it into the classCache.  However as you are only concatenating 5 items className could be changed to a String as follows:
> String className = it.next() + "." + packageName + "." + name;
> This is less code and also removes the need for the toString() method on subsequent uses of the className.
> Patch:
> 85,91c85
> <                 StringBuffer className = new StringBuffer();
> < 
> <                 className.append(it.next());
> <                 className.append('.');
> <                 className.append(packageName);
> <                 className.append('.');
> <                 className.append(name);
> ---
> >                 String className = it.next() + "." + packageName + "." + name;
> 100c94
> <                         servClass = Class.forName(className.toString());
> ---
> >                         servClass = Class.forName(className);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.