Skip to content

http: memory leak if a server is not closed #48604

@mcollina

Description

@mcollina

Version

v18.16.1

Platform

Mac

Subsystem

http

What steps will reproduce the bug?

Run

const http = require('http')

async function main () {
  let i = 0
  while (true) {
    if (i % 100 === 0) {
      global.gc()
    }

    if (i % 100000 === 0) {
      console.log(process.memoryUsage())
    }

    http.createServer((req, res) => {})
    i++
  }
}

main()

How often does it reproduce? Is there a required condition?

All the time

What is the expected behavior? Why is that the expected behavior?

The memory should not grow uncontrolled

What do you see instead?

Memory growing and after many iterations a crash

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions