Skip to content

permessage-deflate keeps a Deflater per session even with server_no_context_takeover #15941

Closed

Description

@stefanroex

Jetty version(s)
12.1.14. 12.0.x and 13.0.x have the same code.

Jetty Environment
core

HTTP version
HTTP/1.1

Java version/vendor (use: java -version)
25

OS type/version
Any

Description
With server_no_context_takeover negotiated, a session should give its deflater back to the pool after each message. It does, but then takes a new one right away.

When the last frame of a message is sent, the extension releases the deflater. Then OutgoingFlusher.onFrame clears the deflater's input, which was added in #13034 for #13029. It gets the deflater through getDeflater(), and because the old one was just released, that takes a new one from the pool. The session keeps it until its next message or until it closes.

Each deflater holds a few hundred KB of native memory, so this adds up with many idle sessions. On a bare 12.1.14 server with ~1,900 open sessions we saw ~1,900 live deflaters and about 1 GB extra RSS.

How to reproduce?

  1. Start a 12.1.x server with a WebSocket endpoint.
  2. Connect a few hundred clients that offer permessage-deflate with server_no_context_takeover.
  3. Send one message from the server to each client.
  4. Count the live deflaters with jcmd <pid> GC.class_histogram | grep 'java.util.zip.Deflater '. There is one per session. It should be only a few, because idle sessions shouldn't hold one.

The test in #15942 does the same directly against the extension and fails without the fix.

Activity

  1. added 5 commits that reference this issue on Oct 9, 2026
  2. added 2 commits that reference this issue on Oct 12, 2026
  3. moved this from 🏗 In progress to ✅ Done in Jetty 12.1.15 - FROZENon Oct 12, 2026
  4. added a commit that references this issue on Oct 12, 2026
  5. lachlan-roberts commented on Oct 12, 2026

    @lachlan-roberts
    Member

    @stefanroex thanks for the PRs!

    They have now been merged into both 12.1.x and 12.0.x branches, and will be available in the next releases of 12.1.15 and 12.0.41.

  6. stefanroex commented on Oct 12, 2026

    @stefanroex
    ContributorAuthor

    Thanks for the review and the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugFor general bugs on Jetty side

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions