diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-10-30 14:40:50 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-02-05 22:26:03 +0100 |
commit | 6b99fd23237d30a269f35690920ed6a4ab75de1a (patch) | |
tree | e3c1ee6582f221cfdaed9bd3c0b30d3b2bc844cb | |
parent | 8d14668992f156d8ec9e5fa31ddd83987db081ea (diff) | |
download | node-6b99fd23237d30a269f35690920ed6a4ab75de1a.tar.gz |
zlib: pass object size hint to V8
Inform V8 that the zlib context object is tied to a large off-heap buffer.
This makes the GC run more often (in theory) and improves the accuracy of
--trace_external_memory.
-rw-r--r-- | src/node_zlib.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 406c042b9..4a60c875d 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -74,9 +74,11 @@ class ZCtx : public ObjectWrap { if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) { (void)deflateEnd(&strm_); + V8::AdjustAmountOfExternalAllocatedMemory(-kDeflateContextSize); } else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW || mode_ == UNZIP) { (void)inflateEnd(&strm_); + V8::AdjustAmountOfExternalAllocatedMemory(-kInflateContextSize); } mode_ = NONE; @@ -375,12 +377,14 @@ class ZCtx : public ObjectWrap { ctx->windowBits_, ctx->memLevel_, ctx->strategy_); + V8::AdjustAmountOfExternalAllocatedMemory(kDeflateContextSize); break; case INFLATE: case GUNZIP: case INFLATERAW: case UNZIP: ctx->err_ = inflateInit2(&ctx->strm_, ctx->windowBits_); + V8::AdjustAmountOfExternalAllocatedMemory(kInflateContextSize); break; default: assert(0 && "wtf?"); @@ -441,6 +445,8 @@ class ZCtx : public ObjectWrap { } private: + static const int kDeflateContextSize = 16384; // approximate + static const int kInflateContextSize = 10240; // approximate bool init_done_; |