preface
- To understand
Java
The area of memory where objects, variables, and so on are stored is very important - This article will give a comprehensive explanation
Java
Memory model & partition in virtual machine, hope you like it
In the coming days, I will publish a series of articles on the JVM, as follows; Interested in sustainable follow Carson_Ho’s Android development notes
Schematic diagram
directory
Schematic diagram
1. Memory model & Partitioning
-
Java
The VIRTUAL machine is runningJava
A program manages one area of memory: the runtime data area - In the runtime data section, it is divided according to usage:
-
Java
Virtual machine stack (stack area) - Local method stack
-
Java
Heap (heap area) - Methods area
- Program counter
-
Schematic diagram
- Below, I’ll describe each memory model partition in detail
2. The Java heap
-
Schematic diagram
Schematic diagram
-
Introduction to the
Schematic diagram
Garbage collection will be explained in an upcoming article
3. Java VM stack
-
Schematic diagram
Schematic diagram
-
Introduction to the
Schematic diagram
4. Local method stack
- Schematic diagram
Schematic diagram
- Introduction to the
Very similarJava
The vm stack differs from the Java VM in the following aspects: Service object, namely
Java virtual machine stack for executionJava
Method service; The local method stack is executionNative
Methods the service
5. Methods area
-
Schematic diagram
Schematic diagram
-
Introduction to the
Schematic diagram
- Note that it contains an internal run-time constant pool, described as follows:
Schematic diagram
6. Program counter
- Schematic diagram
Schematic diagram
- Introduction to the
Schematic diagram
7. Extra knowledge: Direct memory
- Definition:
NIO
Class (JDK
Channel – and buffer-based in 1.4I/O
By usingNative
Out-of-heap memory allocated directly by the library - Features: Not limited by heap size
Not part of the virtual machine run-time data area & not allocated in the heap
- Application scenario: This mode is applicable to frequently invoked scenarios
A DirectByteBuffer object stored in the Java heap is used as a reference to this memory to avoid copying data back and forth between the Java heap and Native heap and improve performance
- Exception thrown:
OutOfMemoryError
That is, the sum with other memory regions is greater than the physical memory limit
8. To summarize
- This article provides a comprehensive overview of the memory model & partitioning in the JVM, summarized below
Schematic diagram
- In the coming days, I’ll be presenting a series of presentations
JVM
Article, as follows; Interested in sustainable concernsCarson_Ho android Development Notes
Schematic diagram
Thumb up, please! Because your encouragement is the biggest power that I write!
The Android event distribution mechanism is the most comprehensive and easy to understand solution for Android screen adaptation. It is the most comprehensive and easy to understand solution for Android screen adaptation. Android development: JSON introduction and the most comprehensive analysis method! BroadcastReceiver Is the most comprehensive version of Android’s BroadcastReceiver
Welcome to attentionCarson_HoJane books!
Share the dry things about Android development from time to time, the pursuit of short, flat, fast, but there is no lack of depth.