Skip to content

Commit 7d66752

Browse files
mdlavinMyles Borins
authored and
Myles Borins
committed
zlib: release callback and buffer after processing
PR-URL: #6955 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yuval Brik <[email protected]>
1 parent 4c423e6 commit 7d66752

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/zlib.js

+10
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,16 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
560560
req.callback = callback;
561561

562562
function callback(availInAfter, availOutAfter) {
563+
// When the callback is used in an async write, the callback's
564+
// context is the `req` object that was created. The req object
565+
// is === this._handle, and that's why it's important to null
566+
// out the values after they are done being used. `this._handle`
567+
// can stay in memory longer than the callback and buffer are needed.
568+
if (this) {
569+
this.buffer = null;
570+
this.callback = null;
571+
}
572+
563573
if (self._hadError)
564574
return;
565575

0 commit comments

Comments
 (0)