博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
对于规范和实现,你会混淆吗?
阅读量:6860 次
发布时间:2019-06-26

本文共 1429 字,大约阅读时间需要 4 分钟。

hot3.png

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

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

川哥,一直有一个疑问。之前了解到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.)

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

转载于:https://my.oschina.net/apdplat/blog/480284

你可能感兴趣的文章
忘记 ROOT 密码怎么办?
查看>>
android单元测试框架中的类
查看>>
C#遍历动态对象属性
查看>>
Mathematica中的尾递归优化
查看>>
Nginx+fastcgi+c语言+jQuery等技术实现设备端web登录
查看>>
QT学习资料
查看>>
Service Mesh:什么是Sidecar模式
查看>>
关于如何将安全意识带入企业的思考
查看>>
反射 注解的解析
查看>>
Docker | 搭建docker本地镜像仓库
查看>>
(转) Python 实现简单的Web服务器
查看>>
关于SVM的那点破事
查看>>
写给java web一年左右工作经验的人
查看>>
Java八种基本数据类型的比较及其相互转化
查看>>
【Java编程规范】 代码书写规范...待续中
查看>>
Qml数据类型
查看>>
float浮点数的二进制存储方式及转换
查看>>
二手X61续
查看>>
如何在 CentOS 7 上禁用 SELinux
查看>>
Android有用代码片断(五)
查看>>