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 rvagg committed Jun 2, 2016
1 parent e4ac808 commit 1e26b82
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
@@ -574,6 +574,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;

0 comments on commit 1e26b82

Please sign in to comment.