Afaf, On 6/21/16 8:46 AM, Afaf Zahkya wrote: > Hello, > > I m using tomcat 8.0.21. > > I want to send *up* to 4 MB of text messages through a websocket connection > to my tomcat server. I set the MaxTextMessageBufferSize to 4 MB.Now as a > result, every time I open a websocket connection and I send a message , I > can see that 4 MB are being allocated in memory for the CharBuffer > messageBufferText regardless of the size of the message I send . 99 % of my > messages would be way smaller.The 4 MB remain allocated in the > messageBufferText CharBuffer even after the message is handled. The > connection can stay open up to 30 minutes in my case, and each websocket > connection is taking 4 MB of memory all of that time even if it's inactive > which leads my server to eventually run out of memory even with inactive > connections . Note that I m using a Whole Message Handler. > > Why not set the messageBufferText CharBuffer size to the payload length if > it doesn't exceed the maxTextMessageBufferSize, and then clearing that > buffer ( reducing its size) after the message is handled by the Handler, so > that inactive connections don't take up memory. ( same for the binary) ? > > Any other / better suggestions on how to solve that problem ?
If you configure Tomcat with maxTextMessageBufferSize="4MB" but only send small messages, do you get a small buffer? Or do you get a 4MB buffer immediately? -chris
signature.asc
Description: OpenPGP digital signature