0

It is commonly said that V8 stores it's objects in heap. Wikipedia describes heap as

a specialized tree-based data structure which is essentially an almost complete binary tree that satisfies the heap property: in a max heap, for any given node C, if P is a parent node of C, then the key (the value) of P is greater than or equal to the key of C.

So I had a look at the V8's HeapObject, but to no success, because I don't know any C++ and it is a quite sophisticated code by itself with lot's of references to other classes etc.

One thing I noticed, that HeapObject itself uses something called Map.

So, how does V8's Heap relate to the heap data structure (as defined in computer science)?

trincot
  • 317,000
  • 35
  • 244
  • 286
tnsaturday
  • 527
  • 2
  • 10
  • 31
  • "The heap" is a common name for a "free store", aka "the place where dynamic memory comes from", though honestly, I've never been able to work out why. I can't imagine how one would implement a free store with/as a heap, which makes me think that this is a good question. https://en.wikipedia.org/wiki/Memory_management#Manual_memory_management – Mooing Duck Apr 17 '23 at 16:38
  • https://en.wikipedia.org/wiki/C_dynamic_memory_allocation#Heap-based and https://en.wikipedia.org/wiki/Data_segment#Heap are both relevant, but neither contains an answer – Mooing Duck Apr 17 '23 at 16:45
  • There is no relationship between the definition of "heap" for memory management, and the heap data structure. It's similar to asking about the word "trunk", and what the relationship is between an oak tree and an elephant's body part. – PaulMcKenzie Apr 17 '23 at 16:47
  • @PaulMcKenzie: In that case this becomes a history/etymology question. Presumably there's a reason it was called a heap in the first place. But I guess that's not what the OP asked. – Mooing Duck Apr 17 '23 at 16:54
  • @MooingDuck the memory heap is an unorganized pile of objects in memory (vs the ordered pile in a stack), a heap is fairly descriptive. Not sure about the data structure though https://stackoverflow.com/questions/1699057/why-are-two-different-concepts-both-called-heap – Alan Birtles Apr 17 '23 at 21:18
  • [What's the relationship between "a" heap and "the" heap?](https://stackoverflow.com/questions/756861/whats-the-relationship-between-a-heap-and-the-heap) – trincot Apr 22 '23 at 06:41

0 Answers0