You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Nikk Folts (Jira)" <ji...@apache.org> on 2021/09/29 21:03:00 UTC

[jira] [Created] (TAP5-2694) Tapestry PlasticClassPool makes thousands of duplicate strings

Nikk Folts created TAP5-2694:
--------------------------------

             Summary: Tapestry PlasticClassPool makes thousands of duplicate strings
                 Key: TAP5-2694
                 URL: https://issues.apache.org/jira/browse/TAP5-2694
             Project: Tapestry 5
          Issue Type: Improvement
          Components: plastic
    Affects Versions: 5.7.3
            Reporter: Nikk Folts


I have completed a memory profile of our Tapestry application, and found that the PlasticClassPool has lots of duplicate Strings in memory. After some investigation, it seems that the InheritanceData#getValue() method is the likely culprit.

Example Strings:
"toString:()"
"get:(Ljava/lang/Object;)"
"getPropertyName:()"

h4. The current method:
{code:java}
    /**
     * Combines a method name and its desc (which describes parameter types and return value) to form
     * a value, which is how methods are tracked.
     */
    private static String toValue(String name, String desc)
    {
        // TAP5-2268: ignore return-type to avoid methods with the same number (and type) of parameters but different
        //            return-types which is illegal in Java.
        // desc is something like "(I)Ljava/lang/String;", which means: takes an int, returns a String. We strip
        // everything after the parameter list.
        int endOfParameterSpecIdx = desc.indexOf(')');

        return name + ":" + desc.substring(0, endOfParameterSpecIdx+1);
    }
{code}

h4. The change is simple one-liner to the return statement:
{code}
return (name + ":" + desc.substring(0, endOfParameterSpecIdx+1)).intern();
{code}





--
This message was sent by Atlassian Jira
(v8.3.4#803005)