diff options
-rw-r--r-- | platform/node/src/node_map.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index fbdd194472..a8ef14f5f7 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -542,12 +542,18 @@ void NodeMap::renderFinished() { auto image_size = img.bytes(); v8::Local<v8::Object> pixels = Nan::NewBuffer( - reinterpret_cast<char*>(img.data.get()), image_size, [](char* buf, void*) { delete[] buf; }, nullptr) - .ToLocalChecked(); + reinterpret_cast<char*>(img.data.get()), image_size, + [](char* buf, void* hint) { + delete[] buf; + std::int64_t* mem_freed = reinterpret_cast<std::int64_t*>(hint); + Nan::AdjustExternalMemory(-(*mem_freed + sizeof(std::int64_t))); + delete mem_freed; + }, new std::int64_t(image_size)) + .ToLocalChecked(); if (!pixels.IsEmpty()) { img.data.release(); } - Nan::AdjustExternalMemory(image_size); + Nan::AdjustExternalMemory(image_size + sizeof(std::int64_t)); v8::Local<v8::Value> argv[] = { Nan::Null(), pixels |