In software development, the programming language Java was historically considered slower than the fastest 3rd generation typed languages such as C and C++. The main reason being a different language design, where after compiling, Java programs run on a Java virtual machine (JVM) rather than directly on the computer's processor as native code, as do C and C++ programs. Performance was a matter of concern because much business software has been written in Java after the language quickly became popular in the late 1990s and early 2000s.
Since the late 1990s, the execution speed of Java programs improved significantly via introduction of just-in-time compilation (JIT) (in 1997 for Java 1.1), the addition of language features supporting better code analysis, and optimizations in the JVM (such as HotSpot becoming the default for Sun's JVM in 2000). Hardware execution of Java bytecode, such as that offered by ARM's Jazelle, was also explored to offer significant performance improvements. The performance of a Java bytecode compiled Java program depends on how optimally its given tasks are managed by the host Java virtual machine (JVM), and how well the JVM exploits the features of the computer hardware and operating system (OS) in doing so.
Thus, any Java performance test or comparison has to always report the version, vendor, OS and hardware architecture of the used JVM. In a similar manner, the performance of the equivalent natively compiled program will depend on the quality of its generated machine code, so the test or comparison also has to report the name, version and vendor of the used compiler, and its activated compiler optimization directives.
JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls the main method present in a java code. JVM is a part of JRE(Java Runtime Environment).
The class loader is a subsystem used for loading class files. It performs three major functions viz. Loading, Linking, and Initialization.
JVM Method Area stores class structures like metadata, the constant runtime pool, and the code for methods.
All the Objects, their related instance variables, and arrays are stored in the heap. This memory is common and shared across multiple threads.
Java language Stacks store local variables, and it’s partial results. Each thread has its own JVM stack, created simultaneously as the thread is created. A new frame is created whenever a method is invoked, and it is deleted when method invocation process is complete.
PC register store the address of the Java virtual machine instruction which is currently executing. In Java, each thread has its separate PC register.
Native method stacks hold the instruction of native code depends on the native library. It is written in another language instead of Java.
It is a type of software used to test hardware, software, or complete systems. The test execution engine never carries any information about the tested product.
The Native Method Interface is a programming framework. It allows Java code which is running in a JVM to call by libraries and native applications.
Native Libraries is a collection of the Native Libraries(C, C++) which are needed by the Execution Engine.
jcmd: 在JDK 1.7之后，新增了一个命令行工具jcmd。它是一个多功能工具，可以用来导出堆，查看java进程，导出线程信息，执行GC等。jcmd拥有jmap的大部分功能，Oracle官方建议使用jcmd代替jmap。
-flag< name >: 打印指定java虚拟机的参数值
-flag [+|-]< name >：设置或取消指定java虚拟机参数的布尔值
-flag < name >=< value >：设置指定java虚拟机的参数的值
jmap pid jmap -heap pid jmap -dump:format=b,file=file_name [pid]
-heap ：打印jvm heap的情况
-histo： 打印jvm heap的直方图。其输出信息包括类名，对象数量，对象占用大小。
-histo：live ： 同上，但是只答应存活对象的情况
-permstat： 打印permanent generation heap情况
jstat -gc PID 5000 20
jhat -J-Xmx1024M [file]
JHat是Sun JDK 6及以上版本中自带的一个用于分析jvm堆dump文件的工具，基于此工具可分析jvm heap中对象的内存占用状况、引用关系等。
jstack [option] vmid
jstat -gc pid 5000
YGC：Young GC（Minor GC）次数
Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one system and can expect it to run on any other Java enabled system without any adjustment. This is all possible because of JVM.
When we compile a .java file, .class files(contains byte-code) with the same class names present in .java file are generated by the Java compiler. This .class file goes into various steps when we run it. These steps together describe the whole JVM.
如有侵权，请联系 email@example.com 删除。