diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-12-03 14:22:26 -0500 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-12-03 15:31:06 -0800 |
commit | f25220b2cfae015709afb68824f6442a2c9f2bef (patch) | |
tree | c6bacb6cfd2e712af4f6fe66ca121731844edd54 /libdeno/internal.h | |
parent | b39f4c146e7c13a7489e37b315a86e1a4a03a1a8 (diff) |
Fix test_cc memory leaks.
These were discovered using the LSAN.
http://dev.chromium.org/developers/testing/leaksanitizer
Diffstat (limited to 'libdeno/internal.h')
-rw-r--r-- | libdeno/internal.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libdeno/internal.h b/libdeno/internal.h index a996a0008..0113946d5 100644 --- a/libdeno/internal.h +++ b/libdeno/internal.h @@ -23,15 +23,26 @@ class DenoIsolate { cb_(cb), next_req_id_(0), user_data_(nullptr) { + array_buffer_allocator_ = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); if (snapshot.data_ptr) { snapshot_.data = reinterpret_cast<const char*>(snapshot.data_ptr); snapshot_.raw_size = static_cast<int>(snapshot.data_len); } } + ~DenoIsolate() { + if (snapshot_creator_) { + delete snapshot_creator_; + } else { + isolate_->Dispose(); + } + delete array_buffer_allocator_; + } + void AddIsolate(v8::Isolate* isolate); v8::Isolate* isolate_; + v8::ArrayBuffer::Allocator* array_buffer_allocator_; deno_buf shared_; const v8::FunctionCallbackInfo<v8::Value>* current_args_; v8::SnapshotCreator* snapshot_creator_; |