JVM (Java Virtual Machine) is an abstract machine, In other words, it is a program/software which takes Java bytecode and converts the byte code (line by line) into machine understandable code.
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 Java code. JVM is a part of the JRE(Java Runtime Environment).
JVM perform some particular types of operations:
- Loading of code
- Verification of code
- Executing the code
- It provide run-time environment to the users
Types of Memory areas allocated by the JVM:
All these functions take different forms of the memory structure. The memory in the JVM divided into 5 different parts:
- Class(Method) Area
- Program Counter Register
- Native Method Stack
Let’s see about them in brief:
- Class Loader:It is a subsystem of JVM which is used to load class files.It is mainly responsible for three activities.
- Class(Method) Area: It stores class level data of every class such as the runtime constant pool, field and method data, the code for methods.
- Heap: It is used to allocate memory to objects at run time
- Each thread has a private JVM stack, created at the same time as thread. It is used to store data and partial results which will be needed while returning value for method and performing dynamic linking.
- Java Stack stores frames and a new frame is created each time at every invocation of the method.
A frame is destroyed when its method invocation completes
- Program Counter Register: Each JVM thread which carries out the task of a specific method has a program counter register associated with it. The non-native method has a PC which stores the address of the available JVM instruction whereas, in a native method, the value of the program counter is undefined. PC register is capable of storing the return address or a native pointer on some specific platform.
- Native method Stacks: Also called as C stacks, native method stacks are not written in Java language. This memory is allocated for each thread when its created And it can be of a fixed or dynamic nature.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to find max memory, free memory and total memory in Java?
- CSS | grid-template-areas Property
- Difference between fundamental data types and derived data types
- what happens when you don't free memory after using malloc()
- Memory leaks in Java
- Difference between Register and Memory
- Java Memory Management
- Difference between Primary and Secondary Memory
- How are Java objects stored in memory?
- R - Creating, Listing, and Deleting Objects in Memory
- What is DIMM(Dual Inline Memory Module)?
- Difference between Contiguous and Noncontiguous Memory Allocation
- Java substring() method memory leak issue and fix
- Thread Interference and Memory Consistency Errors in Java
- R - Data Types
- Number and its Types in Julia
- Types of Vectors in R Programming
- Regression and its Types in R Programming
- What is stream and its types in Node.js ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.