You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2014/03/18 16:54:43 UTC

[jira] [Created] (WICKET-5535) Intern strings generated by Wicket that have bigger chance to be duplicated

Martin Grigorov created WICKET-5535:
---------------------------------------

             Summary: Intern strings generated by Wicket that have bigger chance to be duplicated
                 Key: WICKET-5535
                 URL: https://issues.apache.org/jira/browse/WICKET-5535
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 7.0.0
            Reporter: Martin Grigorov
            Assignee: Martin Grigorov


I've been doing some performance measurements recently and I've noticed that Wicket produces some higher number of String objects like:
- small numbers ("1", "2", "3", ...) generated from repeaters' String.valueOf(nextId)
- HTML element names/attributes ("span", "div", ...) generated in XmlTag#getName, #getAttribute, ...

We can reduce memory usage for those by using String#intern().
Since Java 7 the interned strings are stored in the Heap memory so this won't affect negatively the perm generation.
Interned strings are GC-ed so this is also not a concern.

http://java-performance.info/string-intern-in-java-6-7-8/ provides good explanation how to avoid the CPU penalty caused by String#intern() if needed.



--
This message was sent by Atlassian JIRA
(v6.2#6252)