Java WebSocket client memory leak

80 views Asked by At

I have an application that runs multiple client socket connections. I've noticed that when I send thousands of messages simultaneously, it occasionally generates a memory leak. What could it depend on? Could it be a network problem? Bottleneck?

I'll try to slow down the process of a single message but it is a workaround.

A note: when I run a command GC manually then Garbage Collector frees the memory otherwise it grows constantly.

Thanks in advance.

1

There are 1 answers

0
lance-java On

I found that I was getting memory leaks when using spring-websocket. I'm not sure if the issue was with spring or with tomcat.

I ended up switching to spring-webflux which uses netty under the hood. I haven't had any issues since the move to spring-webflux. Note that the API's are quite different for webflux which uses reactive streams.