jetty.project
jetty.project copied to clipboard
How to disable permessage-deflate extension in Jetty 12.0.5
Jetty Version 12.0.5
Jetty Environment ee10
Java Version openjdk 17.0.10 2024-01-16 LTS
Question How to disable permessage-deflate extension in Jetty 12.0.5 I have checked suggestions provided here https://stackoverflow.com/questions/39538512/using-permessage-deflate-causing-native-memory-leak-in-jetty9-3-11
You could do something like this while configuring websocket:
JettyWebSocketServletContainerInitializer.configure(contextHandler, (context, container) ->
{
WebSocketComponents components = WebSocketServerComponents.getWebSocketComponents(contextHandler);
components.getExtensionRegistry().unregister("permessage-deflate");
// ... Other Configuration
});
You could also just not negotiate the permessage-deflate extension.
It will automatically be negotiated if it was available in the ExtensionRegistry
, but you can remove it.
JettyWebSocketServletContainerInitializer.configure(contextHandler, (context, container) ->
{
container.addMapping("/", (req, resp) ->
{
resp.setExtensions(Collections.emptyList());
return serverSocket;
});
});
Are you actually experiencing a memory leak with permessage-deflate. That post was for Jetty 9.3 which is very old, and we have also done work to address that in the more recent versions, we now use inflater/deflater pools.
Are you actually experiencing a memory leak with permessage-deflate. That post was for Jetty 9.3 which is very old, and we have also done work to address that in the more recent versions, we now use inflater/deflater pools.
Yes, there is some memory leak where in after all the websocket sessions are closed JVM reclaims heap in its entirety to pre load test levels however, k8s pod memory still remains high and not released back to OS. Looks like a native memory leak and here is my post on SO, https://stackoverflow.com/questions/77849478/pod-memory-grows-gradually-during-websocket-load-test-and-not-reclaimed-after-se
@agrawalrahul0305 that stackoverflow issue looks like normal ByteBufferPool behavior, which is used all over the place in Jetty, not just permessage-deflate.