Skip to content

Commit

Permalink
zlib: release callback and buffer after processing
Browse files Browse the repository at this point in the history
PR-URL: #6955
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yuval Brik <yuval@brik.org.il>
  • Loading branch information
mdlavin authored and Myles Borins committed Jun 30, 2016
1 parent 72de1ce commit 395f4be
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,16 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
req.callback = callback;

function callback(availInAfter, availOutAfter) {
// When the callback is used in an async write, the callback's
// context is the `req` object that was created. The req object
// is === this._handle, and that's why it's important to null
// out the values after they are done being used. `this._handle`
// can stay in memory longer than the callback and buffer are needed.
if (this) {
this.buffer = null;
this.callback = null;
}

if (self._hadError)
return;

Expand Down

0 comments on commit 395f4be

Please sign in to comment.