Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit a93424da4aeb03e71c39eab68e0b0588ecb401e1 1 parent 570e4be
@bnoordhuis bnoordhuis authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/node_zlib.cc
View
6 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;
@@ -366,12 +368,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?");
@@ -432,6 +436,8 @@ class ZCtx : public ObjectWrap {
}
private:
+ static const int kDeflateContextSize = 16384; // approximate
+ static const int kInflateContextSize = 10240; // approximate
bool init_done_;
Please sign in to comment.
Something went wrong with that request. Please try again.