Home > Mobile >  Why is 'malloced_memory' lower than 'used_heap_size' in Node.js?
Why is 'malloced_memory' lower than 'used_heap_size' in Node.js?

Time:10-04

In every example of v8.getHeapStatistics() the malloced_memory seems to be lower than used_heap_size:

{
  total_heap_size: 7326976,
  total_heap_size_executable: 4194304,
  total_physical_size: 7326976,
  total_available_size: 1152656,
  used_heap_size: 3476208,
  heap_size_limit: 1535115264,
  malloced_memory: 16384,
  peak_malloced_memory: 1127496,
  does_zap_garbage: 0,
  number_of_native_contexts: 1,
  number_of_detached_contexts: 0
}

How can malloced_memory be lower than used_heap_size? Isn't used_heap_size a subset of malloced_memory?

My assumptions (obviously incorrect, unless malloced_memory is in KB and used_heap_size is in B):

  • malloced_memory: total memory acquired from the OS (needed to create the V8 heap, store Buffers, etc.).
  • used_heap_size: the total size of all objects on the V8 heap (including uncollected garbage).

CodePudding user response:

(V8 developer here.)

Memory for the managed heap is mmaped, not malloced, so it's not expected to be a subset.

  • Related