Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! process: report ArrayBuffer memory in memoryUsage()
  • Loading branch information
addaleax committed Jan 28, 2020
commit 5e624ba5377ff19c680f4a1a2da47cbbfa69c33a
22 changes: 14 additions & 8 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,29 @@ static void HostCleanupFinalizationGroupCallback(
}

void* NodeArrayBufferAllocator::Allocate(size_t size) {
total_mem_usage_ += size;
void* ret;
if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
return UncheckedCalloc(size);
ret = UncheckedCalloc(size);
else
return UncheckedMalloc(size);
ret = UncheckedMalloc(size);
if (LIKELY(ret != nullptr))
total_mem_usage_ += size;
return ret;
}

void* NodeArrayBufferAllocator::AllocateUninitialized(size_t size) {
total_mem_usage_ += size;
return node::UncheckedMalloc(size);
void* ret = node::UncheckedMalloc(size);
if (LIKELY(ret != nullptr))
total_mem_usage_ += size;
return ret;
}

void* NodeArrayBufferAllocator::Reallocate(
void* data, size_t old_size, size_t size) {
total_mem_usage_ += size - old_size;
return static_cast<void*>(
UncheckedRealloc<char>(static_cast<char*>(data), size));
void* ret = UncheckedRealloc<char>(static_cast<char*>(data), size);
if (LIKELY(ret != nullptr) || UNLIKELY(size == 0))
total_mem_usage_ += size - old_size;
Comment thread
addaleax marked this conversation as resolved.
Outdated
return ret;
}

void NodeArrayBufferAllocator::Free(void* data, size_t size) {
Expand Down