-6

Is there any relationship between the heap abstract datastrucuture and Java memory area (heap) where the objects get stored.

If yes, why JVM implementation chooses the heap datastructure to store objects in memory. What is the benefit over other data structures?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
JavaUser
  • 25,542
  • 46
  • 113
  • 139
  • 1
    What research have you done? There's a huge amount of information out there on this topic already. What articles have you read? What did you find confusing about the contents? – Michael Mar 12 '19 at 12:15
  • 2
    related: https://stackoverflow.com/questions/660855/what-is-the-origin-of-the-term-heap-for-the-free-store –  Mar 12 '19 at 12:38

1 Answers1

3

In this case 'heap' refers to the memory area reserved for dynamic memory allocation, not the data structure. They are two completely different concepts, and there is no relationship between them.

user9849588
  • 607
  • 1
  • 7
  • 13
  • so the jvm stack is not the data structure stack? but they all LIFO. – LiLi Jun 08 '20 at 03:36
  • 1
    @LiLi The JVM stacks, on the other hand, are in fact the LIFO data structure stack. Also note that each JVM thread has a private "JVM stack", and each frame (created when a method is invoked) has its own "operand stack", meanwhile the "heap" is shared among all JVM threads. You can read more at the JVM specification https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-2.html – user9849588 Jun 12 '20 at 17:56