Wicket
  1. Wicket
  2. WICKET-4134

Localizer.getCacheKey() generating redundant keys for same values causing memory leak.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.5.2
    • Component/s: wicket
    • Labels:
    • Environment:
      Linux, Jboss/Jetty 4g Ram

      Description

      Note: To reproduce this, just add a breakpoint or a logger in Localizer.addKeyToCache(). After running all pages/scenarios once that method should not be called again. But if it does get called you know that there are redundant keys being produced for the same value.

      After running a web app for about a day, I will get out of mem exception. With a heap dump I will see most of the memory taken by Localizer, with keys such as:

      androidapp-10:_wicket_link-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-28-4-4-4-4-4-4-28-52-4-4-76-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-27-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-28-4-4-4-4-4-4-4-30-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-41-4-4-4-4-26-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-41-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4...

      Each of these types of keys are duplicated several thousand times. Here is a snipplet if the report:

      Found 60 occurrences of char[] with at least 10 instances having identical content. Total size is 401,451,248 bytes.

      Top elements include:

      6,454 x androidapp-10:_wicket_link-4-4-4-4-4-4-4-4-4-4-4-4... (15,722 bytes)
      6,453 x facebook-10:_wicket_link-4-4-4-4-4-4-4-4-4-4-4-4-4... (15,720 bytes)
      5,866 x home-9:_autolink_5-10:_wicket_link-4-4-4-4-4-4-4-4... (15,720 bytes)
      5,183 x candidates-9:_autolink_7-10:_wicket_link-4-4-4-4-4... (15,614 bytes)
      686 x candidates-9:_autolink_8-10:_wicket_link-4-4-4-4-4... (16,567 bytes)

        Issue Links

          Activity

          Hide
          lucius added a comment - - edited

          Heap dump report screenshot attached. thanks again!

          Show
          lucius added a comment - - edited Heap dump report screenshot attached. thanks again!
          Hide
          lucius added a comment - - edited

          OK. tracking a single link I have on a page to see what key is used.

          Going to the exact same URL, One time the getCacheKey generates this key:

          home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-1-en_US-desktop-null

          The subsequent hit will generate this.

          home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-1-en_US-desktop-null

          Trying again a few mins later, 3 consecutive hits to same url:

          home-2:_autolink_29-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-1-en_US-desktop-null
          home-2:_autolink_29-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-1-en_US-desktop-null
          home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-4-1-en_US-desktop-null

          Show
          lucius added a comment - - edited OK. tracking a single link I have on a page to see what key is used. Going to the exact same URL, One time the getCacheKey generates this key: home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-1-en_US-desktop-null The subsequent hit will generate this. home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-1-en_US-desktop-null Trying again a few mins later, 3 consecutive hits to same url: home-2:_autolink_29-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-1-en_US-desktop-null home-2:_autolink_29-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-1-en_US-desktop-null home-2:_autolink_5-3:_wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-4-1-en_US-desktop-null
          Hide
          lucius added a comment -

          As it appends the cursorId, I noticed this id keeps getting longer each page hit
          [TransparentWebMarkupContainer [Component id = _wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-4-4]]

          Show
          lucius added a comment - As it appends the cursorId, I noticed this id keeps getting longer each page hit [TransparentWebMarkupContainer [Component id = _wicket_link-4-27-4-4-4-27-27-4-4-4-4-4-4-4-25-4-4-4-4-38-4-4-4-4-28-28-4-4] ]
          Hide
          lucius added a comment -

          As a work around for now I am changing getCacheKey so the following is happening, skipping the appedending of id for TransparentWebMarkupContainer. It will probably break some applications but it's ok for mine.

          final boolean skip = parent instanceof AbstractRepeater || cursor instanceof TransparentWebMarkupContainer;

          if (skip == false)

          { buffer.append(':').append(cursor.getId()); }
          Show
          lucius added a comment - As a work around for now I am changing getCacheKey so the following is happening, skipping the appedending of id for TransparentWebMarkupContainer. It will probably break some applications but it's ok for mine. final boolean skip = parent instanceof AbstractRepeater || cursor instanceof TransparentWebMarkupContainer; if (skip == false) { buffer.append(':').append(cursor.getId()); }
          Hide
          lucius added a comment -

          this component also generates a new id, on a form submit:
          [AutolinkBookmarkablePageLink [Component id = _autolink_203]]

          causing a new key to be cached every click to a submit post back.

          Show
          lucius added a comment - this component also generates a new id, on a form submit: [AutolinkBookmarkablePageLink [Component id = _autolink_203] ] causing a new key to be cached every click to a submit post back.
          Hide
          lucius added a comment -

          same problem with WebComponent for a button like this <input type="submit" wicket:message="value:uploadPhoto"/>
          [Component id = _message_attr_159]

          the message_attr_159 is a new id every post back

          Show
          lucius added a comment - same problem with WebComponent for a button like this <input type="submit" wicket:message="value:uploadPhoto"/> [Component id = _message_attr_159] the message_attr_159 is a new id every post back
          Hide
          lucius added a comment -

          Thanks for fixing! Just curious what was the fix applied?

          Show
          lucius added a comment - Thanks for fixing! Just curious what was the fix applied?
          Show
          Martin Grigorov added a comment - http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Localizer.java/?rev=1185501&view=diff&r1=1185501&r2=1185500&p1=/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Localizer.java&p2=/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Localizer.java

            People

            • Assignee:
              Igor Vaynberg
              Reporter:
              lucius
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development