Skip to content

Commit 6717af6

Browse files
mdlavinFishrock123
authored andcommitted
zlib: release callback and buffer after processing
PR-URL: nodejs#6955 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yuval Brik <[email protected]>
1 parent 1005bd0 commit 6717af6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/zlib.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,16 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
574574
req.callback = callback;
575575

576576
function callback(availInAfter, availOutAfter) {
577+
// When the callback is used in an async write, the callback's
578+
// context is the `req` object that was created. The req object
579+
// is === this._handle, and that's why it's important to null
580+
// out the values after they are done being used. `this._handle`
581+
// can stay in memory longer than the callback and buffer are needed.
582+
if (this) {
583+
this.buffer = null;
584+
this.callback = null;
585+
}
586+
577587
if (self._hadError)
578588
return;
579589

0 commit comments

Comments
 (0)