当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

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

发表于: 2015-07-19   作者:yangshangchuan   来源:转载   浏览:
摘要: 昨晚和朋友聊天,喝了点咖啡,由于我经常喝茶,很长时间没喝咖啡了,所以失眠了,于是起床读JVM规范,读完后在朋友圈发了一条信息: JVM Run-Time Data Areas:The Java Virtual Machine defines various run-time data areas that are used during execution of a program. So

昨晚和朋友聊天,喝了点咖啡,由于我经常喝茶,很长时间没喝咖啡了,所以失眠了,于是起床读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.)

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

 

 

 

 

 

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

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号