Why are reference types stored in a heap?

In some languages, dynamically allocated objects are stored in the heap. Looking at a complexity table of data structures (like this one) I see that the only advantage heaps have over some other type of data structures such as a tree is dealing with the maximal value better.

Why is the heap used to store those objects and not other data structures?
Is dealing with the maximal value important for memory management? Why?


The "heap" which is used to store dynamically allocated objects is completely unrelated to the data structure which is called a "heap". They are two completely different things with the same name.

See Wikipedia for a reference on both kinds of heaps. It links to one article for "Heap (data structure)", and another for "Heap (free store)".

链接地址: http://www.djcxy.com/p/14542.html

上一篇: PermGen和Metaspace有什么区别?

下一篇: 为什么参考类型存储在堆中?