mirror of
https://github.com/lovell/sharp.git
synced 2026-02-05 14:16:17 +01:00
Add runtime detection of V8 memory cage #3384
When using the V8 memory cage, Buffers cannot be wrapped and then later freed via a callback. When the cage is detected via a throw, instead fall back to copying Buffer contents to V8 memory. This approach will be used by Electron 21+ and you should expect reduced performance and increased memory consumption/fragmentation.
This commit is contained in:
@@ -1206,8 +1206,8 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
// Add buffer size to info
|
||||
info.Set("size", static_cast<uint32_t>(baton->bufferOutLength));
|
||||
// Pass ownership of output data to Buffer instance
|
||||
Napi::Buffer<char> data = Napi::Buffer<char>::New(env, static_cast<char*>(baton->bufferOut),
|
||||
baton->bufferOutLength, sharp::FreeCallback);
|
||||
Napi::Buffer<char> data = sharp::NewOrCopyBuffer(env, static_cast<char*>(baton->bufferOut),
|
||||
baton->bufferOutLength);
|
||||
Callback().MakeCallback(Receiver().Value(), { env.Null(), data, info });
|
||||
} else {
|
||||
// Add file size to info
|
||||
|
||||
Reference in New Issue
Block a user