当前位置:网站首页>JVM principle
JVM principle
2022-07-28 10:18:00 【Chi Ge who loves sharing】
One 、 Class loading
1、 Start class loader
Extend the classloader
Apply the class loader : User defined class loading
2、 Parents delegate : For example, when user-defined classes are loaded, they will ask their superiors , Until the class loader is started to load , If the startup class loader cannot complete the loading task , It is still left to the first requested class loading ( Here is the application class loader ). The advantage of this is , After the same class is loaded by different class loaders , Not the same class , It will cause confusion in the management of these classes , And if it is all started by the class loader java.lang.Object Classes are generated in the same Object The next is the same class , Easy to manage .
Two 、gc Garbage collection
( Reference resources https://www.sohu.com/a/235928510_100123073)
Three perspectives to understand gc:
1jvm How to determine which objects should be recycled ?
Two classical algorithms for whether objects will be recycled :
Reference counting ( Not quoted , If it is a circular reference , Can't solve this problem , such as a,b,a Call in b,b call a)
* Reachability analysis algorithm ( The virtual machine uses a directed graph , The program treats all references as a graph , Through a series called GC Roots As the starting point , Start with these nodes and drill down , The path a search takes is called a reference chain . When an object arrives GC Roots There's no chain of references connected ( It's from GC Roots It's impossible to reach this object ) when , Then prove that this object is not available . Pictured :)
2jvm When will garbage collection be performed ?
answer :1 Will be in cpu Automatically recycle when free 2 After the heap memory is full 3 Active call System.gc() Try recycling after
3jvm How to clear garbage objects ?
The algorithm has four more : Mark - Clear algorithm , Copy algorithm , Mark - Sorting algorithm , Generational collection algorithm ( The new generation , Old age , Forever (1.8 And later called metadata area ))
1、System.gc() and Runtime.gc() What will be done ?
These two methods are used to prompt JVM To recycle . however , Whether garbage collection starts immediately or is delayed depends on JVM Of .
2、 But there is one kind. JNI(Java Native Interface) call non-Java Program (C or C++),finalize() My job is to recycle this part of memory .
3、. If a reference to an object is set to null, Whether the garbage collector will immediately release the memory occupied by objects ?
Can't , In the next garbage collection cycle , This object will be recyclable .
边栏推荐
猜你喜欢

uni-app项目目录、文件作用介绍 及 开发规范

5. Dynamic programming -- Fibonacci series

What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?

Guangzhou metro line 14 xinshixu station is under construction, and residents in Baiyun District are about to start a double line transfer mode!
![[esp32][esp idf] esp32s3 quickly build lvglv7.9](/img/39/8efef047d0a9223b97819a54b5edf8.png)
[esp32][esp idf] esp32s3 quickly build lvglv7.9

Performance test of API gateway APIs IX in Google cloud T2a and T2D

Typora使用教程

It's settled! On July 30!

SuperMap iServer发布管理以及调用地图服务

关于软考高级要不要报班学习
随机推荐
Aqua Data Studio 18.5.0导出insert语句
第四步-用户开发环境设置
4.调整数组顺序使奇数位于偶数前面
Leetcode -- minimum number of rotation array
双指针技巧
2. 输出数组中重复的数字之一
16、字符串反转
ELK实时日志分析平台
What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
问题总结档案
Netease written test No. 2 -- typical application of European distance
select如果不加order by子句,返回结果的顺序是不可靠的
Choosing a supplier service system is the first step for large health industry enterprises to move towards digital transformation
[esp32][esp idf][lvgl7.9] failed to compile with OLED IIC
Kubernetes
02.1.2.逻辑类型 bool
初识SuperMap iDesktop
Step 4 - user development environment settings
MySQL的SQL TRACE一例
语音聊天app——如何规范开发流程?