随笔分类 - jvm
Java虚拟机
摘要:在部分的商用虚拟机(Sun HotSpot、IBM J9)中,Java程序最初是通过解释器(Interpreter)进行解释执行的,当虚拟机发现某个方法或代码块的运行特别频繁时,就会把这些代码认定为 “热点代码”(Hot Spot Code)。为了提高热点代码的执行效率,在运行时,虚拟机将会把这些代
阅读全文
摘要:jps 查看java进程的PID java -XX:+PrintFlagsInitial 显示所有可设置参数及默认值 java -XX:+PrintFlagsFinal 获取到所有可设置参数及值(手动设置之后的值) java -XX:+PrintCommandLineFlags 显示出JVM初始化完
阅读全文
摘要:1.下载Apache Maven 3.5.3 http://maven.apache.org/download.cgi apache-maven-3.5.3-bin.zip 解压为C:\maven3 在系统环境变量加入PATH后加入maven3的bin目录C:\maven3\bin C:\Users
阅读全文
摘要:java的类加载机制 一.类加载是什么? 类加载过程即是指JVM虚拟机把.class文件中类信息加载进内存,并进行解析生成对应的class对象的过程。 举个通俗点的例子来说,JVM在执行某段代码时,遇到了class A, 然而此时内存中并没有class A的相关信息,于是JVM就会到相应的class
阅读全文
摘要:Resolution:简单地说就是将符号引用转化为直接引用。 在JVM指令集中,anewarray, checkcast, getfield,getstatic, instanceof, invokedynamic, invokeinterface, invokespecial, invokesta
阅读全文
摘要:类(如果无特殊说明,本文中的“类”表示类和接口,下同)的初始化主要包括初始化的同步及执行其初始化方法<clinit>。 在以下几种情况下会触发类的初始化: (1)执行JVM指令:new、getstatic、putstatic、invokestatic,会触发指令后的引用所指向类的初始化(若未初始化)
阅读全文
摘要:方法区(Method Area)与Java堆一样,是各个线程共享的内存区域,它用于存储已被虚拟机加载的类信息、常量、静态变量、即时编译器编译后的代码等数据。虽然Java虚拟机规范把方法区描述为堆的一个逻辑部分,但是它却有一个别名叫做Non-Heap(非堆),目的应该是与Java堆区分开来。对于习惯在
阅读全文
摘要:For each type it loads, a Java Virtual Machine must store the following kinds of information in the method area: 对每个装载的类型,虚拟机都会在方法区中存储以下类型信息: The full
阅读全文
摘要:For each type it loads, a Java Virtual Machine must store a constant pool. A constant pool is an ordered set of constants used by the type, including
阅读全文
摘要:For each field declared in the type, the following information must be stored in the method area. In addition to the information for each field, the o
阅读全文
摘要:For each method declared in the type, the following information must be stored in the method area. As with fields, the order in which the methods are
阅读全文
摘要:Class variables are shared among all instances of a class and can be accessed even in the absence of any instance. These variables are associated with
阅读全文
摘要:For each type it loads, a Java Virtual Machine must keep track of whether or not the type was loaded via the primordial class loader or a class loader
阅读全文
摘要:An instance of class java.lang.Class is created by the Java Virtual Machine for every type it loads. The virtual machine must in some way associate a
阅读全文
摘要:As an example of how the Java Virtual Machine uses the information it stores in the method area, consider these classes: 为了展示虚拟机如何使用方法区中的信息,我们举个例子,看下面
阅读全文
摘要:对于大多数应用来说,Java堆(Java Heap)是Java虚拟机所管理的内存中最大的一块。Java堆是被所有线程共享的一块内存区域,在虚拟机启动时创建。此内存区域的唯一目的就是存放对象实例,几乎所有的对象实例都在这里分配内存。这一点在Java虚拟机规范中的描述是:所有的对象实例以及数组都要在堆上
阅读全文
摘要:程序计数器(Program Counter Register)是一块较小的内存空间,它的作用可以看做是当前线程所执行的字节码的行号指示器。在虚拟机的概念模型里(仅是概念模型,各种虚拟机可能会通过一些更高效的方式去实现),字节码解释器工作时就是通过改变这个计数器的值来选取下一条需要执行的字节码指令,分
阅读全文