对于规范和实现,你会混淆吗?

编程技术  /  houtizong 发布于 2年前   120

昨晚和朋友聊天,喝了点咖啡,由于我经常喝茶,很长时间没喝咖啡了,所以失眠了,于是起床读JVM规范,读完后在朋友圈发了一条信息:

JVM Run-Time Data Areas:The Java Virtual Machine defines various run-time data areas that are used during execution of a program. Some of these data areas are created on Java Virtual Machine start-up and are destroyed only when the Java Virtual Machine exits. Other data areas are per thread. Per-thread data areas are created when a thread is created and destroyed when the thread exits. http://url.cn/eyfKNQ

早上起床后发现了一个朋友的回复:

川哥,一直有一个疑问。之前了解到Java内存对于堆内存分为新生代,老年带,永久带,而常量池和字节码文件归属于永久带内存,这里为啥又属于方法区了~对于Java内存分为堆和非堆又是以什么维度划分的

我的回复如下:

你之前的了解没有错,"permanent generation"(永久带)是JVM规范的实现之一(即HotSpot)的概念,“Method Area”(方法区)是JVM规范中的概念,在JVM规范中明确指出:方法区逻辑上是堆的一部分,规范没有强制指定方法区在内存中的位置(参见规范2.5.4节描述: Although the method area is logically part of the heap, simple implementations may choose not to either garbage collect or compact it. This specification does not mandate the location of the method area or the policies used to manage compiled code.)在最新的HotSpot中,已经移除了"permanent generation":The Permanent Generation (PermGen) space has been replaced by a new space called Metaspace. 至于如何区分堆(heap)和非堆(non heap),我认为需要把握堆的定义,一开始说堆是用于存储类实例(class instances )和数组(arrays),后来又说方法区(Method Area)逻辑上也是堆的一部分,当然,除了这两部分,其他的都是非堆(non heap)了(参见规范2.5.3节描述:The heap is the run-time data area from which memory for all class instances and arrays is allocated.)

有不同想法或疑惑的同学欢迎一起讨论!

 

 

 

 

 

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客