当前位置:网站首页>jvm之方法区
jvm之方法区
2022-07-30 05:45:00 【zpv2jdfc】
方法区主要是存储类信息、常量的地方,也叫非堆。首先看一下官方文档对方法区的描述:
The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process. It stores per-class structures such as the run-time constant pool, field and method data, and the code for methods and constructors, including the special methods (§2.9) used in class and instance initialization and interface initialization. The method area is created on virtual machine start-up. 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. The method area may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger method area becomes unnecessary. The memory for the method area does not need to be contiguous. A Java Virtual Machine implementation may provide the programmer or the user control over the initial size of the method area, as well as, in the case of a varying-size method area, control over the maximum and minimum method area size. The following exceptional condition is associated with the method area:
If memory in the method area cannot be made available to satisfy an allocation request, the Java Virtual Machine throws an OutOfMemoryError.
简单来说,方法区是线程共享的,主要用来存储类的结构,比如:运行时常量池、字段和方法数据,以及方法和构造函数的代码,包括类和实例初始化以及接口初始化中使用的特殊方法。
虚拟机规范文档对方法区的要求挺宽泛的,实现或不实现GC、大小固定或者可以拓展、内存是否连续都可以。但jdk1.8中hotspot是实现了GC的,元空间直接分配在本地内存,自然也就是可拓展的了。
另外,jdk1.6->1.7->1.8这之间,hotspot方法区的变化还是很大的。在1.6中,方法区叫永久代;在1.7中把字符串常量池和静态变量移除到了堆中;1.8则直接改成了元空间并且直接分配在本地内存。
边栏推荐
- 【速成MSP430f149】电赛期间学习MSP430f149笔记
- 十三、Kotlin进阶学习:内联函数let、also、with、run、apply的用法。
- 边境的悍匪—机器学习实战:第三章 分类
- 【Qingdao Station】High-level application of SWAT model and modeling of areas without data, uncertainty analysis and climate change, improvement of land use surface pollution impact model and case analy
- Trust anchor for certification path not found. Exception solution.
- 基于MATLAB 2021b的机器学习、深度学习
- QT串口动态实时显示大量数据波形曲线(四)========“界面的美化与处理”
- 通过位运算进行字符大小写转换
- Kotlin协程的简单用法:1、GlobalScope(不建议使用);2、lifecycleScope、viewModelScope(建议使用);
- protobuf coding and network communication applications (1)
猜你喜欢

CNN经典模型发展进程

十一、Kotlin进阶学习:1、集合;2、List操作;3、可变集合——MutableList;4、Set;5、Map;6、MutableMap;

【江科大自化协stm32F103c8t6】笔记之【入门32单片机及EXTI外部中断初始化参数配置】

遥感、GIS和GPS技术在水文、气象、灾害、生态、环境及卫生等应用

2021年软考中级过关

三种内核结构---宏内核、微内核、混合内核

QT每周技巧(3)~~~~~~~~~串口添加

protobuf coding and network communication applications (1)

二叉树(一):深度优先遍历与广度优先遍历

大气颗粒物 PMF 源解析
随机推荐
六、Kotlin基础学习:函数
The application of Meta analysis in the field of ecological environment
C语言学习经验
二叉树(一):深度优先遍历与广度优先遍历
边境的悍匪—机器学习实战:第十一章 训练深度神经网络
DeepLearing4j's deep learning Yolo Tiny realizes target detection
边境的悍匪—机器学习实战:第十六章使用RNN和注意力机制进行自然语言处理
基于OpenCV的双目重建
Machine Learning, Deep Learning Based on MATLAB 2021b
QT连载4:基于QT和STM32H750的LORA试验平台(3)
[Getting C language from zero basis - navigation summary]
【江科大自化协stm32F103c8t6】笔记之【入门32单片机及GPIO初始化参数配置】
influxDB运维记录
MySQL data types and footprint
R语言 生态环境领域应用
Generalized Focal Loss 论文阅读笔记
QT串口动态实时显示大量数据波形曲线(四)========“界面的美化与处理”
MATLAB怎么在图像中显示nii文件切片信息?
边境的悍匪—机器学习实战:第一章 机器学习的基础知识
Xcode 绑定按钮点击事件