Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5535

Intern strings generated by Wicket that have bigger chance to be duplicated

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.0.0-M1
    • 7.0.0-M1
    • wicket
    • None

    Description

      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.

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            mgrigorov Martin Tzvetanov Grigorov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: