- 浏览: 352776 次
- 性别:
- 来自: 南京
博客专栏
-
设计模式那些事儿
浏览量:5790
文章分类
- 全部博客 (85)
- news (3)
- java面试题 (3)
- java基础 (2)
- 英语短文 (2)
- 英语演讲 (2)
- Weekly Address (5)
- 英语写作 (2)
- 转载 (1)
- 2010 FIFA World Cup (5)
- Scrum (1)
- 计算机基础 (2)
- java引用对象 (1)
- 英语阅读 (1)
- Ext (6)
- Javascript (3)
- Web编程 (4)
- 战国策 (7)
- html (1)
- java (33)
- concurrency (1)
- jvm (31)
- 方法区 (9)
- 栈 (5)
- 堆 (1)
- 程序计数器 (1)
- 本地方法栈 (1)
- class file (5)
- 常量池 (2)
- attributes (1)
- 连接模型 (1)
- applet (1)
- gc (5)
- 垃圾收集 (5)
- 方法调用 (2)
- IBM (0)
- 门户(Portal) (0)
- Solr (1)
- Lucene (1)
- 全文检索 (1)
- 设计模式 (4)
- 责任链模式 (1)
- 责任链 (1)
- COR (1)
- Pattern (1)
最新评论
-
Nabulio:
是不错的
Java的Integer与int互转 -
shihengli2010:
学习了 !Integer i = 100; Integer ...
Java的Integer与int互转 -
flex涵:
还可以,差不多就是这个意思.
Java的Integer与int互转 -
lijingshou:
相当好用。。。
输入年月日格式yyyyMMdd,判断是否是周末 -
denverj:
你好,是这本书的英文版,名字叫<Inside the J ...
JVM学习笔记-帧数据区(Frame Data)
与程序计数器一样,Java虚拟机栈(Java Virtual Machine Stacks)也是线程私有的,它的生命周期与线程相同。虚拟机栈描述的是Java方法执行的内存模型:每个方法被执行的时候都会同时创建一个栈帧(Stack Frame①)用于存储局部变量表、操作栈、动态链接、方法出口等信息。每一个方法被调用直至执行完成的过程,就对应着一个栈帧在虚拟机栈中从入栈到出栈的过程。
经常有人把Java内存区分为堆内存(Heap)和栈内存(Stack),这种分法比较粗糙,Java内存区域的划分实际上远比这复杂。这种划分方式的流行只能说明大多数程序员最关注的、与对象内存分配关系最密切的内存区域是这两块。其中所指的“堆”在后面会专门讲述,而所指的“栈”就是现在讲的虚拟机栈,或者说是虚拟机栈中的局部变量表部分。
局部变量表存放了编译期可知的各种基本数据类型(boolean、byte、char、short、int、float、long、double)、对象引用(reference类型,它不等同于对象本身,根据不同的虚拟机实现,它可能是一个指向对象起始地址的引用指针,也可能指向一个代表对象的句柄或者其他与此对象相关的位置)和returnAddress类型(指向了一条字节码指令的地址)。
其中64位长度的long和double类型的数据会占用2个局部变量空间(Slot),其余的数据类型只占用1个。局部变量表所需的内存空间在编译期间完成分配,当进入一个方法时,这个方法需要在帧中分配多大的局部变量空间是完全确定的,在方法运行期间不会改变局部变量表的大小。
在Java虚拟机规范中,对这个区域规定了两种异常状况:如果线程请求的栈深度大于虚拟机所允许的深度,将抛出StackOverflowError异常;如果虚拟机栈可以动态扩展(当前大部分的Java虚拟机都可动态扩展,只不过Java虚拟机规范中也允许固定长度的虚拟机栈),当扩展时无法申请到足够的内存时会抛出OutOfMemoryError异常。
以上描述截取自:
《深入理解Java虚拟机:JVM高级特性与最佳实践》 作者: 周志明
----------------------------------------------------------------------------------------------------------------------------------
When a new thread is launched, the Java Virtual Machine creates a new Java stack for the thread. As mentioned earlier, a Java stack stores a threadís state in discrete frames. The Java Virtual Machine only performs two operations directly on Java Stacks: it pushes and pops frames.
每当启动一个新线程时,Java虚拟机都会为它分配一个Java栈。前面我们曾经提到,Java栈以帧为单位保存线程的运行状态。虚拟机只会直接对Java栈执行两种操作:以帧为单位的压栈或出栈。
The method that is currently being executed by a thread is the thread’s current method. The stack frame for the current method is the current frame. The class in which the current method is defined is called the current class, and the current classís constant pool is the current constant pool. As it executes a method, the Java Virtual Machine keeps track of the current class and current constant pool. When the virtual machine encounters instructions that operate on data stored in the stack frame, it performs those operations on the current frame.
某个线程正在执行的方法被称为该线程的当前方法,当前方法使用的栈帧成为当前帧,当前方法所属的类成为当前类,当前类的常量池成为当前常量池。在线程执行一个方法时,它会跟踪当前类和当前常量池。此外,当虚拟机遇到栈内操作指令时,它对当前帧内数据执行操作。
When a thread invokes a Java method, the virtual machine creates and pushes a new frame onto the threadís Java stack. This new frame then becomes the current frame. As the method executes, it uses the frame to store parameters, local variables, intermediate computations, and other data.
每当线程调用一个Java方法时,虚拟机都会在该线程的Java栈中压入一个新帧。而这个新帧自然就成为了当前帧。在执行这个方法时,它使用这个帧来存储参数、局部变量、中间运算结果等等数据。
A method can complete in either of two ways. If a method completes by returning, it is said to have normal completion. If it completes by throwing an exception, it is said to have abrupt completion. When a method completes, whether normally or abruptly, the Java Virtual Machine pops and discards the method’s stack frame. The frame for the previous method then becomes the current frame.
Java方法可以以两种方式完成。一种通过return返回的,称为正常返回;一种是通过抛出异常而异常中止的。不管以哪种方式返回,虚拟机都会将当前帧弹出Java栈然后释放掉,这样上一个方法的帧就成为当前帧了。
All the data on a threadís Java stack is private to that thread. There is no way for a thread to access or alter the Java stack of another thread. Because of this, you need never worry about synchronizing multi-threaded access to local variables in your Java programs. When a thread invokes a method, the methodís local variables are stored in a frame on the invoking threadís Java stack. Only one thread can ever access those local variables: the thread that invoked the method.
Java栈上的所有数据都是此线程私有的。任何线程都不能访问另一个线程的栈数据,因此我们不需要考虑多线程情况下栈数据的访问同步问题。当一个线程调用一个方法时,方法的局部变量保存在调用线程Java栈的帧中。只有一个线程总是访问哪些局部变量,即调用方法的线程。
Like the method area and heap, the Java stack and stack frames need not be contiguous in memory. Frames could be allocated on a contiguous stack, or they could be allocated on a heap, or some combination of both. The actual data structures used to represent the Java stack and stack frames is a decision of implementation designers. Implementations may allow users or programmers to specify an initial size for Java stacks, as well as a maximum or minimum size.
像方法区和堆一样,Java栈和帧在内存中也不必是连续的。帧可以分步在连续的栈里,也可以分步在堆里,或者二者兼而有之。表示Java栈和栈帧的实际数据结构由虚拟机的实现者决定。某些实现允许用户指定Java栈的初始大小和最大最小值。
以上描述截取自:
《Inside the Java Virtual Machine 2nd Edition》 作者:Bill Venners
发表评论
-
java书籍
2011-12-15 15:31 0线程 Java Concurrency in Pra ... -
JVM学习笔记-本地方法调用(Invoking a Native Method)
2011-11-25 11:56 1164Invoking a Native Method ... -
JVM学习笔记-调用Java方法(Invoking a Java Method)
2011-11-25 11:35 1518Invoking a Java Method As m ... -
JVM学习笔记-分代收集器(Generational Collectors)
2011-11-23 14:41 1929Generational Collectors ... -
JVM学习笔记-拷贝收集器(Copying Collectors)
2011-11-22 16:34 1610Copying Collectors Copy ... -
JVM学习笔记-压缩收集器(Compacting Collectors)
2011-11-22 16:17 1330Compacting Collectors G ... -
JVM学习笔记-跟踪收集器(Tracing Collectors)
2011-11-22 16:04 1919Tracing Collectors Trac ... -
JVM学习笔记-引用计数收集器(Reference Counting Collectors)
2011-11-22 15:46 2500Reference Counting Collect ... -
applet notinited的解决方案
2011-11-13 14:45 4527最近项目当中正好使用到了applet,这个很少接触过的东东。 ... -
JVM学习笔记-动态连接和解析(Dynamic Linking and Resolution)
2011-11-08 11:09 3443When you compile a Java pro ... -
JVM学习笔记-属性格式(Attributes Types)
2011-11-07 12:15 1487Attributes The Java Vir ... -
JVM学习笔记-属性(Attributes)
2011-11-07 12:03 1521Attributes As mentioned ... -
JVM学习笔记-方法(Methods)
2011-11-07 11:25 2228Methods Each method dec ... -
JVM学习笔记-字段(Fields)
2011-11-07 11:17 1916Each field (class variable a ... -
JVM学习笔记-特殊字符串(Special Strings)
2011-11-05 14:33 1672Special Strings 特殊字符串 T ... -
JVM学习笔记-Class文件(Class File)
2011-11-05 14:39 1595What is a Java Class Fi ... -
JVM学习笔记-本地方法栈(Native Method Stacks)
2011-11-02 10:16 19195本地方法栈(Native Me ... -
JVM学习笔记-帧数据区(Frame Data)
2011-10-28 09:16 1724In addition to the local var ... -
JVM学习笔记-操作数栈(Operand Stack)
2011-10-27 11:12 14095Like the local variables, th ... -
JVM学习笔记-局部变量区(Local Variables)
2011-10-27 10:42 3004The local variables secti ...
相关推荐
jvm 调优笔记-jvm
Moonbox(月光宝盒)是JVM-Sandbox生态下的,基于jvm-sandbox-repeater重新开发的一款流量回放平台产品。在jvm-sandbox-repeater基础上提供了更加丰富功能,同时便于线上部署和使用,更多对比参考。 使用场景 你...
nginx-upstream-jvm-route 支持nginx版本1.15 解决nginx: [emerg] invalid parameter "srun_id=tomcat1" 问题
JVM调优总结 -Xms -Xmx -Xmn -Xss
赠送jar包:metrics-jvm-3.1.5.jar; 赠送原API文档:metrics-jvm-3.1.5-javadoc.jar; 赠送源代码:metrics-jvm-3.1.5-sources.jar; 赠送Maven依赖信息文件:metrics-jvm-3.1.5.pom; 包含翻译后的API文档:...
jvm-full-gc调优-jvm-full-gc
赠送jar包:metrics-jvm-3.1.5.jar; 赠送原API文档:metrics-jvm-3.1.5-javadoc.jar; 赠送源代码:metrics-jvm-3.1.5-sources.jar; 赠送Maven依赖信息文件:metrics-jvm-3.1.5.pom; 包含翻译后的API文档:...
JVM性学习笔记-基本原理,内存模型,JVM参数设置,类加载器原理,JDK自带工具
nginx-upstream-jvm-route-0.1.tar.gz 用来实现Nginx Tomcat 集群session复制的问题!
mini-jvm in rust实现jvm,jvm-rs-main.zip
代码如下:failed to create jvm error code -4 这一般应是内存不够用所致,解决方法参考如下。 打开 Android Studio 安装目录下的bin目录,查找并打开文件 studio.exe.vmoptions,修改代码: 代码如下:-Xmx512m 为...
2.5.4 堆(heap)和栈(stack) 20 JAVA垃圾收集器 21 3.1 垃圾收集简史 21 3.2 常见的垃圾收集策略 21 3.2.1 Reference Counting(引用计数) 22 3.2.2 跟踪收集器 22 3.3 JVM的垃圾收集策略 27 3.3.1 Serial Collector ...
JVM调优总结 -Xms -Xmx -Xmn -Xss JVM调优总结 -Xms -Xmx -Xmn -Xss
nginx_upstream_jvm_route 是一个 Nginx 的扩展模块,用来实现基于 Cookie 的 Session Sticky 的功能。 安装方法(进入Nginx源码目录): #patch -p0 < /path/to/this/directory/jvm_route.patch # ./configure -...
JVM,MIB,可通过SNMP协议监控JVM运行情况
jvm内存结构-栈的变化,机器指令的格式/执行模式文章中的demo代码。
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
jvm性能调优-jvm内存模型和优化-performance-jvm-memorymodel-optimize
jvm调优学习-optimizeJVM
Java分布式应用学习笔记-谈JVM