-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: memory leak if a server is not closed #48604
Comments
To be honest I don't think this is a bug. It's like opening sockets and never closing them. |
Sorry, my bad, I did not notice that there is no |
I can reproduce even with an async loop so it's not that. |
This seems to fix the issue diff --git a/lib/_http_server.js b/lib/_http_server.js
index 0242e7a089..571ed15c6d 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -549,7 +549,7 @@ function Server(options, requestListener) {
this.timeout = 0;
this.maxHeadersCount = null;
this.maxRequestsPerSocket = 0;
- setupConnectionsTracking(this);
+ // setupConnectionsTracking(this);
this[kUniqueHeaders] = parseUniqueHeadersOption(options.uniqueHeaders);
}
ObjectSetPrototypeOf(Server.prototype, net.Server.prototype);
cc: @ShogunPanda |
Maybe we should call |
It makes sense to me, there is no connection to track if the server is not listening. |
That is fine, but it does not explain the leak. I'll try to dig into this in the next few days. |
I think because the anonymous function hold the server object. setInterval(checkConnections.bind(server), server.connectionsCheckingInterval).unref(); |
Yes, I confirm that is the issue. I'll move that call in a listen even as suggested. |
Version
v18.16.1
Platform
Mac
Subsystem
http
What steps will reproduce the bug?
Run
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
The text was updated successfully, but these errors were encountered: