title: Tomcat gradually running out of memory with WebSocket apps deployed
body: <p>I have Tomcat 8.5.9 running on an AWS box with 10 different WebSocket apps deployed that each basically act as a message broker. The https connector is using the Http11NioProtocol. The only parameter I have set is the maxThreads=200 along with the certificate info.  </p>
  
  <p>The request volume is not very high.  It has been running since Monday morning, and here is what the manager status says:</p>
  
  <blockquote>
    <p>Max threads: 200<br>
    Current thread count: 38<br>
    Current thread busy: 0<br>
    Keep alive sockets count: 1<br>
    Max processing time: 234 ms<br>
    Processing time: 17.254 s<br>
    Request count: 33351<br>
    Error count: 325<br>
    Bytes received: 0.00 MB<br>
    Bytes sent: 34.07 MB</p>
  </blockquote>
  
  <p>After a few days, I notice the memory usage continue to grow.  I have to restart Tomcat services about every two weeks or so to prevent getting an OutOfMemoryException.</p>
  
  <p>I have been taking heap dumps and analyzing using the Eclipse MAT, which always points to the WsFrameServer class as being the problem suspect.  The most recent dump displays the following:</p>
  
  <blockquote>
    <p>5,146 instances of "org.apache.tomcat.websocket.server.WsFrameServer",<br>
    loaded by "java.net.URLClassLoader @ 0x6c0047c28" occupy 1,383,143,200<br>
    (73.13%) bytes. These instances are referenced from one instance of<br>
    "java.util.concurrent.ConcurrentHashMap$Node[]"</p>
  </blockquote>
  
  <p>The Dominator Tree is currently has 106,000 entries, most of which are the WsFrameServer class.  </p>
  
  <p>Am I doing something wrong or is this "normal"?  Are there any specific settings either on Tomcat or on the Connector that I should be setting to prevent this from happening?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: I'm not sure if this is helpful, but here is what the VisualVM monitor looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/uh7b4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uh7b4.png" alt="VisualVM Monitor"></a></p>