Runtime Data Areas:
The Java virtual machinedefines various runtime data areas that are used during execution of aprogram. 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.
每個(gè)線程都擁有自己的數(shù)據(jù)區(qū),在線程啟動(dòng)的時(shí)候創(chuàng)建,在線程消亡的時(shí)候銷(xiāo)毀。
1. PC Register
The Java virtual machine can support many threads of execution at once.EachJava virtual machine thread has its own PC (program counter) register.At any point, each Java virtual machine thread is executing the code of asingle method, the current method forthat thread. If that method is not NATIVE, the PC register contains theaddress of the Java virtual machine instruction currently beingexecuted. If the method currently being executed by the thread isNATIVE, the value of the Java virtual machine's PC register isundefined. The Java virtual machine's PC register is wide enough to holda returnAddress or a native pointer on the specific platform.
jvm支持同時(shí)有許多線程在運(yùn)行,每個(gè)jvm線程都擁有自己的PCRegister。在每個(gè)時(shí)刻,每個(gè)jvm線程在執(zhí)行一個(gè)該線程當(dāng)前的方法。若該方法不是NATIVE代碼,則PCRegister包括了當(dāng)前jvm執(zhí)行的指令。若該方法是NATIVE代碼,則不會(huì)定義PC Register。PCRegister的數(shù)據(jù)范圍足夠容納返回地址和所依賴(lài)的平臺(tái)上本地指針。
2. Stacks
Each Java virtual machine thread has a private Java virtual machine stack, created at the same time as the thread. AJava virtual machine stack stores frames. A Java virtual machine stackis analogous to the stack of a conventional language such as C: it holdslocal variables and partial results, and plays a part in methodinvocation and return. Because the Java virtual machine stack is nevermanipulated directly except to push and pop frames, frames may be heapallocated. The memory for a Java virtual machine stack does not need tobe contiguous.
每個(gè)jvm線程都有一個(gè)私有的Stack,在線程創(chuàng)建的時(shí)候隨之產(chǎn)生。jvm Stack存儲(chǔ)的是frames.jvm的Stack類(lèi)似于傳統(tǒng)的C語(yǔ)的Stack:存儲(chǔ)局部變量和返回結(jié)果,與方法的調(diào)用和返回有關(guān)。因?yàn)閖vmStack從來(lái)不是被直接操作除了壓入、彈出frame之外,所以frames可以是堆分配的。每個(gè)jvm Stack的內(nèi)存也沒(méi)有必要是連續(xù)的。
The Java virtual machinespecification permits Java virtual machine stacks either to be of afixed size or to dynamically expand and contract as required by thecomputation. If the Java virtual machine stacks are of a fixed size, thesize of each Java virtual machine stack may be chosen independentlywhen that stack is created. A Java virtual machine implementation mayprovide the programmer or the user control over the initial size of Javavirtual machine stacks, as well as, in the case of dynamicallyexpanding or contracting Java virtual machine stacks, control over themaximum and minimum sizes.
jvm Specification允許jvmStack為固定大小,也充許根據(jù)估計(jì)值動(dòng)態(tài)的擴(kuò)展。如果jvm Stack是固定大小,則創(chuàng)建Stack的時(shí)候,每個(gè)jvmStack大小都是獨(dú)立選擇的。jvm的實(shí)現(xiàn)可能支持編程人員和用戶(hù)控制在jvmStack的初始大小的基礎(chǔ)上控制stack的大小,同樣地在動(dòng)態(tài)地?cái)U(kuò)展或縮小jvm Stack的大小這種情況下,stack大小在最大最小值之間。
jvm Stack可以產(chǎn)生兩種異常:
3. Heap
The Java virtual machine has a heapthat is shared among all Java virtual machine threads. The heap is theruntime data area from which memory for all class instances and arraysis allocated.
jvm的heap是被所有jvm線程共享的一塊區(qū)域。所有的類(lèi)實(shí)例和數(shù)組都是在heap中分配內(nèi)存。
The heap is created on virtualmachine start-up. Heap storage for objects is reclaimed by an automaticstorage management system (known as a garbage collector);objects are never explicitly deallocated. The Java virtual machineassumes no particular type of automatic storage management system, andthe storage management technique may be chosen according to theimplementor's system requirements. The heap may be of a fixed size ormay be expanded as required by the computation and may be contracted if alarger heap becomes unnecessary. The memory for the heap does not needto be contiguous.
Heap在jvm啟動(dòng)的時(shí)候創(chuàng)建的,它存儲(chǔ)對(duì)象Objects,這些objects可以被GC回收,objects從來(lái)不會(huì)被顯示的銷(xiāo)毀。Jvm沒(méi)有特定的存儲(chǔ)自動(dòng)管理系統(tǒng),存儲(chǔ)管理技術(shù)可以根據(jù)需要實(shí)現(xiàn)的系統(tǒng)要求進(jìn)行選擇。Heap可以是固定的大小,也可以是根據(jù)估算進(jìn)行擴(kuò)展,也可以縮小如果一個(gè)比較大的heap變得無(wú)用時(shí)。Heap的內(nèi)存不要求是連續(xù)的。
Java virtual machineimplementation may provide the programmer or the user control over theinitial size of the heap, as well as, if the heap can be dynamicallyexpanded or contracted, control over the maximum and minimum heap size.
jvm的實(shí)現(xiàn)可能提供編程人員和用戶(hù)在初始大小的基礎(chǔ)上控制heap的大小,如果heap可以動(dòng)態(tài)的擴(kuò)展或者縮小,則可以在最大小最值的基礎(chǔ)上靈活控制。Z
jvm Heap可以產(chǎn)生一種異常:
聯(lián)系客服