Skip to content

Possible memory leak in http2 #21332

Closed
Closed
@cTn-dev

Description

@cTn-dev
  • Version: v10.4.1
  • Platform: Windows 10 x64, Ubuntu 18.04 x64
  • Subsystem: http2

Hi, this is my first bug report for node, hopefully i get it right!

TLDR: http2session.request appears to be leaking memory outside of javascript (heap is clean, resident set size keeps growing).

I am attaching a rather crude test code which demonstrates the issue and is able to repro it every time.
The zip file attached contains client.js, server.js and "keys" folder containing self signed SSL keys.

http2test.zip

  1. start the server (it will be running on port 8080) node server.js
  2. start the client node --expose-gc client.js
  3. let the client run for a little while

Depending on the performance of your machine, you should see the "test output" in < 15 seconds or so.

What happens

  1. client will establish connection to the server and make 1 request
  2. after we get a reply we save current process.memoryUsage() for later comparison
  3. client will send 5 parallel requests 20 000 times to the server, 100k total
  4. we will trigger GC and wait for 10 seconds, then trigger GC again (i need heapTotal to shrink and this seems to work)
  5. we will grab the latest process.memoryUsage and calculate the delta for rss, heapTotal and heapUsed

You should get an output similar to this
Deltas: 0 KB Heap Total, -52 KB Heap Used, 10436 KB RSS

Feel free to play with the amount of requests you make, obviously higher number takes longer to execute but leaves much higher rss.

Here is a graph of rss, heap total and heap used over 24h on a system that does ~30k> requests per day, it has been running for several days (hence the larger rss).

24h

Sorry i wasn't able to narrow it down any further (took me over a month to trace the issue this far in my system as it kept leaking rather slowly and doing heap snapshot comparison never revealed anything).

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.memoryIssues and PRs related to the memory management or memory footprint.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions