0

As per the question What and where are the stack and heap?, I more or less have an understanding of stack memory vs heap memory. Another question comes to mind, however:

Most sources I've read describe stack memory as being represented by an actual stack data structure in the memory. Is it the same with heap memory? Is heap memory represented/abstracted by a min/max heap data structure? If not, then what data structure is used to implement heap memory?

Community
  • 1
  • 1
brain56
  • 2,659
  • 9
  • 38
  • 70
  • Hi! I noticed the close vote. I would like to know how the question is unclear. It seems pretty straightforward to me. Thanks! – brain56 Apr 10 '14 at 03:51
  • I just did some more searching and identified my question as a duplicate. – brain56 Apr 10 '14 at 04:05

1 Answers1

1

It all depends on the programming language you are using, but stack and heap are traditionally implemented as a stack and tree. The stack may be used to store function calls and scopes because you can return to the calling function by popping. But this and the actual implementation can be different per language so there isn't a general answer to this question.

  • It's also actually different per operating system, and even then there are different allocators that will allocate memory in different ways ;) – aruisdante Apr 10 '14 at 03:56