JVM note2

A heap is a tree data structure where higher levels of the tree always contain greater (or lesser, if it's set up that way) values than lower levels.

 

Donald Knuth says (The Art of Computer Programming, Third Ed., Vol. 1, p. 435):

Several authors began about 1975 to call the pool of available memory a 'heap.' But in the present series of books, we will use that word only in its more traditional sense related to priority queues.

 

 

"The" heap is a bunch of free RAM that a program has available for dynamic allocation.

 

还有两幅形象的图片对比heap和stack

 

  • stack(In a stack of items, items sit one on top of the other in the order they were placed there, and you can only remove the top one (without toppling the whole thing over).)

  • heap(In a heap, there is no particular order to the way items are placed. You can reach in and remove items in any order because there is no clear 'top' item.)

 

 

从百度百科上看到一句话,“由于Stack的内存管理是顺序分配的,而且定长,不存在内存回收问题;而Heap 则是随机分配内存,不定长度,存在内存分配和回收的问题;” Why?

这个问题需要测试一下。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值