code: protected void startPurge() {
          final boolean bTrace = TraceComponent.isAnyTracingEnabled();
          if (bTrace && tc.isEventEnabled()) {
              Tr.event(tc, "Running purge of expired sessions");
          }
          try {
              List<SessionImpl> toPurge = new ArrayList<SessionImpl>();
              for (Map<String, SessionImpl> sessions : this.groupings.values()) {
                  synchronized (sessions) {
                      // scan for all expired sessions
                      for (SessionImpl session : sessions.values()) {
                          if (session.checkExpiration(false)) {
                              toPurge.add(session);
                          }
                      }
                      // now remove those sessions from the map (outside the
                      // iteration loop)
                      for (SessionImpl session : toPurge) {
                          sessions.remove(session.getId());
                      }
                  } // end-sync
  
                  // now iterate that list outside the lock (involves calling
                  // session listeners)
                  for (SessionImpl session : toPurge) {
                      // if the session is still "valid" then we need to call
                      // invalidate now
                      if (bTrace && tc.isDebugEnabled()) {
                          Tr.debug(tc, "Purging session; " + session);
                      }
                      if (!session.isInvalid()) {
                          session.invalidate();
                      }
                  }
                  toPurge.clear();
              } // end-grouping-loop
          } catch (Throwable t) {
              FFDCFilter.processException(t, getClass().getName(), "purge");
              if (bTrace && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Error while running purge scan; " + t);
              }
          }
      }
docs: Method used by the recurring session purge event to scan for and
  discard expired sessions. This prevents memory build up when sessions
  are no longer queried by clients.