JVM规范2-5章节Run-Time-Data-Areas运行时数据区译解

2.5.2 Java Virtual Machine Stacks

Each Java Virtual Machine thread has a private Java Virtual Machine stack, created at the same time as the thread. A Java Virtual Machine stack stores frames (§2.6). A Java Virtual Machine stack is analogous to the stack of a conventional language such as C: it holds local variables and partial results, and plays a part in method invocation and return. Because the Java Virtual Machine stack is never manipulated directly except to push and pop frames, frames may be heap allocated. The memory for a Java Virtual Machine stack does not need to be contiguous.

每个Java虚拟机线程都有一个私有Java虚拟机栈,与该线程同时创建.Java虚拟机栈存储Frame参考(第2.6节).Java虚拟机栈类似于C之类的常规语言的栈:它保存方法调用和返回时的局部变量和部分结果.Java虚拟机栈的内存不必是连续的。

  • In the First Edition of The Java® Virtual Machine Specification, the Java Virtual Machine stack was known as the Java stack.
  • 在第一版中的Java®虚拟机规范,Java虚拟机堆被称为Java栈。

This specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand and contract as required by the computation. If the Java Virtual Machine stacks are of a fixed size, the size of each Java Virtual Machine stack may be chosen independently when that stack is created.

该规范允许Java虚拟机栈具有固定大小,或者根据计算要求动态扩展和收缩.如果Java虚拟机栈的大小固定,则在创建每个Java虚拟机栈时可以独立选择它们的大小。

  • If Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an OutOfMemoryError.
  • 如果线程中的计算需要比允许的Java虚拟机更大的栈,则Java虚拟机将抛出StackOverflowError.

The following exceptional conditions are associated with Java Virtual Machine stacks:
以下异常条件与Java虚拟机栈相关:

  • A Java Virtual Machine implementation may provide the programmer or the user control over the initial size of Java Virtual Machine stacks, as well as, in the case of dynamically expanding or contracting Java Virtual Machine stacks, control over the maximum and minimum sizes
  • Java虚拟机实现可以提供程序员或用户对Java虚拟机栈的初始大小的控制,以及在动态扩展或收缩Java虚拟机栈的情况下,对最大和最小大小的控制.
  • If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError.
  • 如果可以动态扩展Java虚拟机栈,并尝试进行扩展,但是可以提供足够的内存来实现扩展,或者如果没有足够的内存来为新线程创建初始Java虚拟机栈,则Java虚拟机机器抛出一个OutOfMemoryError.

2.5.3 Heap

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads. The heap is the run-time data area from which memory for all class instances and arrays is allocated.
Java虚拟机具有一个在所有Java虚拟机线程之间共享的堆.堆是运行时数据区,从中分配了所有类实例和数组的内存.

The heap is created on virtual machine start-up. Heap storage for objects is reclaimed by an automatic storage management system (known as a garbage collector); objects are never explicitly deallocated. The Java Virtual Machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor’s system requirements. The heap may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger heap becomes unnecessary. The memory for the heap does not need to be contiguous.
堆是在虚拟机启动时创建的.对象的堆存储由自动存储管理系统(称为垃圾收集器)回收;对象永远不会显式释放.Java虚拟机不假定特定类型的自动存储管理系统,可以根据实现者的系统要求选择存储管理技术.堆的大小可以是固定的,也可以根据计算的需要进行扩展,如果不需要更大的堆,则可以将其收缩.堆的内存不必是连续的.

  • A Java Virtual Machine implementation may provide the programmer or the user control over the initial size of the heap, as well as, if the heap can be dynamically expanded or contracted, control over the maximum and minimum heap size.
  • Java虚拟机实现可以为程序员或用户提供对堆的初始大小的控制,并且,如果可以动态扩展或收缩堆,则可以控制最大和最小堆大小.

The following exceptional condition is associated with the heap: 以下异常情况与堆相关联:

  • If a computation requires more heap than can be made available by the automatic storage management system, the Java Virtual Machine throws an OutOfMemoryError.
  • 如果计算需要的堆多于自动存储管理系统可以提供的堆,则Java虚拟机将抛出一个 OutOfMemoryError.

2.5.4 Method Area

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 used in class and interface initialization and in instance initialization (§2.9).
Java虚拟机具有在所有Java虚拟机线程之间共享的方法区域.该方法区域类似于常规语言的编译代码的存储区域,或者类似于操作系统过程中的"文本"段.它存储每个类的结构,例如运行时常量池,字段和方法数据,以及方法和构造函数的代码,包括用于类和接口初始化以及实例初始化(第2.9节)的特殊方法.

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.
  • Java虚拟机实现可以为程序员或用户提供对方法区域初始大小的控制,以及在方法区域大小可变的情况下,可以控制最大和最小方法区域大小.

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.
  • 如果无法提供方法区域中的内存来满足分配请求,则Java虚拟机将抛出一个OutOfMemoryError.

2.5.5 Run-Time Constant Pool

A run-time constant pool is a per-class or per-interface run-time representation of the constant_pool table in a class file (§4.4). It contains several kinds of constants, ranging from numeric literals known at compile-time to method and field references that must be resolved at run-time. The run-time constant pool serves a function similar to that of a symbol table for a conventional programming language, although it contains a wider range of data than a typical symbol table.
甲运行时间常数池是的每个类或每个接口的运行时表示constant_pool在表class文件(§4.4).它包含多种常量,范围从编译时已知的数字文字到必须在运行时解析的方法和字段引用.运行时常量池的功能类似于常规编程语言的符号表,尽管它包含的数据范围比典型的符号表还大.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值