JMeter-WebSocketSampler icon indicating copy to clipboard operation
JMeter-WebSocketSampler copied to clipboard

Server Memory Leak connectionList Service Sockets Not being Removed

Open swordmaster2k opened this issue 9 years ago • 0 comments

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.
    }

swordmaster2k avatar Nov 06 '15 11:11 swordmaster2k