Skip to content
Closed
Show file tree
Hide file tree
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! fixup! process: report ArrayBuffer memory in memoryUsage()
  • Loading branch information
addaleax committed Jan 29, 2020
commit a6e74b3ee79a224a34a244bfce66b38d13dd98b7
6 changes: 4 additions & 2 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ void* NodeArrayBufferAllocator::AllocateUninitialized(size_t size) {
void* NodeArrayBufferAllocator::Reallocate(
void* data, size_t old_size, size_t size) {
void* ret = UncheckedRealloc<char>(static_cast<char*>(data), size);
if (LIKELY(ret != nullptr) || UNLIKELY(size == 0))
total_mem_usage_ += size - old_size;
if (LIKELY(ret != nullptr) || UNLIKELY(size == 0)) {
total_mem_usage_ += size;
total_mem_usage_ -= old_size;
Comment thread
addaleax marked this conversation as resolved.
Outdated
}
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class NodeArrayBufferAllocator : public ArrayBufferAllocator {

private:
uint32_t zero_fill_field_ = 1; // Boolean but exposed as uint32 to JS land.
std::atomic<uint64_t> total_mem_usage_ {0};
std::atomic<size_t> total_mem_usage_ {0};
};

class DebuggingArrayBufferAllocator final : public NodeArrayBufferAllocator {
Expand Down