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

Memory leak in WicketEndpoint

    XMLWordPrintableJSON

Details

    Description

      Our application OOMed yesterday after about 2-3 weeks of continuous uptime. We normally deploy every other day, so we never noticed this issue before.

      The heap dump identified the possible culprit as WicketEndpoint$ApplicationListener:

      Every new websocket connection registers a new instance of this application listener and after a while we ended up with millions of these listeners:

      @Override
      public void onOpen(Session session, EndpointConfig endpointConfig)
      {
          String appName = getApplicationName(session);
      
          WebApplication app = (WebApplication) WebApplication.get(appName);
          app.getApplicationListeners().add(new ApplicationListener(applicationDestroyed));
      
          try
          {
              ThreadContext.setApplication(app);
              javaxWebSocketProcessor = new JavaxWebSocketProcessor(session, app, endpointConfig);
          }
          finally
          {
              ThreadContext.detach();
          }
      }
      

      Instead of creating a new listener for every connection, the listener should be a singleton.

      Attachments

        1. image-2022-03-21-16-27-37-798.png
          50 kB
          Thomas Heigl
        2. image-2022-01-10-18-52-42-193.png
          27 kB
          Thomas Heigl

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              thomas.heigl Thomas Heigl
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: