From c9e3ba6e46527966c46a4f24771749c70e836fdd Mon Sep 17 00:00:00 2001 From: rogertyang Date: Sun, 26 Jan 2025 11:40:16 +0800 Subject: [PATCH 1/2] http: be more generational GC friendly Avoid any potential ref to Buffer in new generation from old generation --- lib/_http_outgoing.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 23b850d1522c97..035037a6ba6817 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -1218,6 +1218,8 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) { // Refs: https://github.com/nodejs/node/pull/30958 for (let i = 0; i < outputLength; i++) { const { data, encoding, callback } = outputData[i]; + // avoid any potential ref to Buffer in new generation from old generation + outputData[i].data = null; ret = socket.write(data, encoding, callback); } socket.uncork(); From e90637178b8c7fa6dcaca7871c98190e39253bc3 Mon Sep 17 00:00:00 2001 From: rogertyang Date: Mon, 27 Jan 2025 11:10:10 +0800 Subject: [PATCH 2/2] http: be more generational GC friendly Fix lint --- lib/_http_outgoing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 035037a6ba6817..5816a34efa4ace 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -1218,8 +1218,8 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) { // Refs: https://github.com/nodejs/node/pull/30958 for (let i = 0; i < outputLength; i++) { const { data, encoding, callback } = outputData[i]; - // avoid any potential ref to Buffer in new generation from old generation - outputData[i].data = null; + // Avoid any potential ref to Buffer in new generation from old generation + outputData[i].data = null; ret = socket.write(data, encoding, callback); } socket.uncork();