Search code examples
node.jsmemoryv8

NodeJS v8.getHeapSpaceStatistics() meaning


I'm learning about memory management of chrome v8 engine,

const v8 = require('v8');

console.log(v8.getHeapSpaceStatistics())

what does read_only_spacemap_space mean?


Solution

  • Those are different parts of V8's managed heap. As their names imply, read_only_space is for read-only data (and should have constant size throughout the lifecycle of your app), and map_space is for what V8 internally calls "maps" (a.k.a. "shape descriptors" or "hidden classes"; note this has nothing to do with a JavaScript new Map()). Most of your app's memory usage will be in old_space, and possibly large_object_space if you allocate very large objects.