fshutdown / JMeter-WebSocketSampler

JMeter - WebSocket Sampler
Apache License 2.0
309 stars 191 forks source link

Server Memory Leak connectionList Service Sockets Not being Removed #44

Open swordmaster2k opened 8 years ago

swordmaster2k commented 8 years ago

I've been running some pretty heavy continuous soak tests using this sampler and I've discovered a memory leak related to the connectionList declared in the ServiceSocket class. Basically what I am doing is looping my threads infinitely and each WebSocketSampler has a unique connection ID for debugging purposes.

Overtime the connectionList HashMap is gradually filling up resulting in the JVMs heap overflowing with redundant references. I've implemented a fix locally that just removes the connection from the collection when it is closed:

@OnWebSocketClose
    public void onClose(int statusCode, String reason) {
       <output omitted>
        close(StatusCode.NORMAL, "JMeter closed session.");
        parent.getConnectionList().remove(connectionID); // Remove from collection to prevent leakage.
    }