Commit a9468782 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Remove leaks in default page allocator

The first leak only happens if the default platform does not provide a
page allocator, which is never the case in d8. I am not sure why the
second leak was not detected so far. Anyway, this CL removes it.

R=tebbi@chromium.org

Change-Id: I215435f28a498298034e1657e7d2ebb8db8450c4
Reviewed-on: https://chromium-review.googlesource.com/c/1392197Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58498}
parent d3d13e4b
......@@ -41,22 +41,16 @@ void* AlignedAllocInternal(size_t size, size_t alignment) {
class PageAllocatorInitializer {
public:
PageAllocatorInitializer() {
v8::PageAllocator* page_allocator =
V8::GetCurrentPlatform()->GetPageAllocator();
if (page_allocator == nullptr) {
// On the heap and leaked so that no destructor needs to run at exit time.
static auto* default_allocator = new v8::base::PageAllocator;
page_allocator = default_allocator;
page_allocator_ = V8::GetCurrentPlatform()->GetPageAllocator();
if (page_allocator_ == nullptr) {
static base::LeakyObject<base::PageAllocator> default_page_allocator;
page_allocator_ = default_page_allocator.get();
}
#if defined(LEAK_SANITIZER)
{
// On the heap and leaked so that no destructor needs to run at exit time.
static auto* lsan_allocator =
new v8::base::LsanPageAllocator(page_allocator);
page_allocator = lsan_allocator;
}
static base::LeakyObject<base::LsanPageAllocator> lsan_allocator(
page_allocator_);
page_allocator_ = lsan_allocator.get();
#endif
page_allocator_ = page_allocator;
}
PageAllocator* page_allocator() const { return page_allocator_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment