The Java™ Virtual machine (JVM) is the application that executes a Java program and it is included in the Java package.
Java API classes: Java API classes are the predefined classes required for the program compilation and interpretation.
The Java Runtime Environment (JRE), also known as Java Runtime, is part of the Java Development Kit (JDK), a set of programming tools for developing Java applications. The Java Runtime Environment provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.
You can have one JVM per process. Since an OS supports many processes, you can have many JVMs running.
When ever we start a new java process by invoking java.exe (i.e. java [class-name] ) a new instance of JVM is created. Each java process executes in its separate JVM environment – we can specify different JVM parameter for each process
JVM is the main component of Java architecture and it is the part of the JRE (Java Runtime Enviroment) . JVM is a part of Java Run Time Environment that is required by every operating system requires a different JRE .
Each operating system and CPU architecture requires a JRE.
JVM Runtime Environment contains the two parts such as:
Java Virtual Machine: JVM is also a part of the JRE. The Java Virtual Machine is responsible for interpreting Java bytecode, and translating this into actions or operating system calls .
Without the availability of a JRE for a given environment, it is impossible to run Java software.
During installation, Java Runtime Environment also deploys a plugin that facilitates the execution of applets within local browsers.
JVM is not platform independent.
The Windows JVM is different from the Unix JVM or the Linux JVM. But, your Java code can run on all three without being changed or recompiled (again, unless you interface to native methods, or use other platform-specific stuff).
Java "the language" is platform-independent. To make it so, there is a platform-specific JRE that knows how to run the platform-independent Java code on a specific platform.
Every supported operating system has its own JVM.
JDK includes a JRE as as subset. The JRE provides runtime support for Java applications. The SDK provides the Java compiler and other development tools. The SDK includes the JRE.
When we download JRE, there are different platforms to choose. That means JRE is machine dependent,
In one machine we can create more than 1 JVM. Suppose in load testing there is a problem in JVM then its not a good practice to increase the size of JVM to solve the performance issue.
For analysizing the JVM many tools are available:
1.JProfiler
In one machine we can create more than 1 JVM. Suppose in load testing there is a problem in JVM then its not a good practice to increase the size of JVM to solve the performance issue.
For analysizing the JVM many tools are available:
1.JProfiler
You can have one JVM per process. Since an OS supports many processes, you can have many JVMs running.
When ever we start a new java process by invoking java.exe (i.e. java [class-name] ) a new instance of JVM is created. Each java process executes in its separate JVM environment – we can specify different JVM parameter for each process
More details:
Performance monitoring tool or command (UNIX) by which we can monitor the JVM behavior and statistics
Jconsole - standard freely available
Yourkit profiler - licensed
Netbeans profiler - freely available.
Yourkit profiler - licensed
Netbeans profiler - freely available.
JPerfmeter: Its gud one.
What is Heap:
Java objects reside in an area called the heap. The heap is created when the JVM starts up and may increase or decrease in size while the application runs. When the heap becomes full, garbage is collected.Whenever we create any object, it’s always created in the Heap space.
JMV memory model:
JVM memory is divided into separate parts. At broad level, JVM Heap memory is physically divided into two parts – Young Generation and Old Generation.
Young Generation: Young generation is the place where all the new objects are created. When young generation is filled, garbage collection is performed. This garbage collection is called Minor GC. Young Generation is divided into three parts – Eden Memory and two Survivor Memory spaces.
Important Points about Young Generation Spaces:
- Most of the newly created objects are located in the Eden memory space.
- When Eden space is filled with objects, Minor GC is performed and all the survivor objects are moved to one of the survivor spaces.
- Minor GC also checks the survivor objects and move them to the other survivor space. So at a time, one of the survivor space is always empty.
- Objects that are survived after many cycles of GC, are moved to the Old generation memory space. Usually it’s done by setting a threshold for the age of the young generation objects before they become eligible to promote to Old generation.
All the Garbage Collections are “Stop the World” events because all application threads are stopped until the operation completes.Since Young generation keeps short-lived objects, Minor GC is very fast and the application doesn’t get affected by this.However Major GC takes longer time because it checks all the live objects. Major GC should be minimized because it will make your application unresponsive for the garbage collection duration. So if you have a responsive application and there are a lot of Major Garbage Collection happening, you will notice timeout errors.
Permanent Generation:Permanent Generation or “Perm Gen” contains the application metadata required by the JVM to describe the classes and methods used in the application. Note that Perm Gen is not part of Java Heap memory.Perm Gen is populated by JVM at runtime based on the classes used by the application. Perm Gen also contains Java SE library classes and methods. Perm Gen objects are garbage collected in a full garbage collection.
Heap Size:
Increasing the maximum heap size setting can improve startup. When you increase the maximum heap size, you reduce the number of garbage collection occurrences with a 10 percent gain in performance.
Increasing this setting usually improves throughput until the heap becomes too large to reside in physical memory. If the heap size exceeds the available physical memory, and paging occurs, there is a noticeable decrease in performance.
Therefore, it is important that the value you specify for this property allows the heap to be contained within physical memory.
What is the process for understanding min heap requirement for a java application?
Best practice is to keep min and max heap memory same..
Heap Dump Analysis
Heap dump analysis means to understand what is going into heap. The general idea is to dump out the contents of the JVM’s memory into a file, then analyze it using a tool.
No comments:
Post a Comment