当前位置:网站首页>GC garbage collection
GC garbage collection
2022-08-07 17:25:00 【haha tea】
GC means garbage collection (Gabage Collection), and memory processing is a place where programmers are prone to problems. Forgetting or wrong memory recycling can lead to programsOr the system is unstable or even crashes. The GC function provided by Java can automatically monitor whether the object exceeds the scope to achieve the purpose of automatic memory recovery. The Java language does not provide a display operation method to release the allocated memory.
What is the rationale for the garbage collector?
For GC, when the programmer creates an object, the GC starts to monitor the address, size and usage of the object.Generally, GC records and manages all objects in the heap in a directed graph manner.In this way it is determined which objects are "reachable" and which objects are "unreachable".When the GC determines that some objects are "unreachable", it is the responsibility of the GC to reclaim the memory space.
Can the garbage collector reclaim memory right away?Is there any way to proactively notify the virtual machine for garbage collection?
Yes. Yes.Programmers can manually execute System.gc() to notify the GC to run, but the Java language specification does not guarantee that the GC will be executed.
Key points of the garbage collection mechanism
1. The garbage collection mechanism only reclaims the object space in the JVM heap memory.
2. Powerless to other physical connections, such as database connection, input stream output stream, Socket connection.
3. The current JVM has a variety of garbage collection implementation algorithms, with different performances.
4. The occurrence of garbage collection is unpredictable, and the program cannot precisely control the execution of the garbage collection mechanism.
5. The reference variable of the object can be set to null, implying that the garbage collection mechanism can recycle the object.
6. Programmers can notify the system to perform garbage collection through System.gc() or Runtime.getRuntime().gc(). There will be some effects, but it is still uncertain whether the system will perform garbage collection.
7. Before any object is reclaimed by the garbage collection mechanism, its finalize method is always called first (if the method is overridden and the object is re-referenced by a new reference variable, the object will be reactivated).
8. Never actively call the finalize method of an object, it should be called by the garbage collection mechanism.
边栏推荐
- FutureTask源码深度剖析
- 一文看懂Filter过滤器
- What is the development of the spot options contract exchange system丨Detailed technology for the development of the spot options contract exchange system
- [Interview Preparation Chapter] Jiwang (1) Basics - 1 TCP/IP Network Model
- 轻松解决笔记本触摸板失灵有妙招
- 企鹅电竞登录鉴权系统架构与核心数据热备容灾方案
- 电脑开机显示器黑屏怎么回事_开机显示器黑屏怎么解决
- w7电脑格式化怎么弄 笔记本电脑如何格式化win7
- 客户流失?来看看大厂如何基于spark+机器学习构建千万数据规模上的用户留存模型
- 电脑上看电视没有声音怎么办 台式电脑看视频没声音怎么办
猜你喜欢

What to do if the game is not compatible with the win7 system

笔记本电脑可以连接电视吗 笔记本接电视的图文教程

Concurrent programming essays necessary for interviews
![would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!](/img/a6/f1dd7a603f267d977400aed9b318dc.png)
would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!

excel打印区域怎么调整 excel 打印区域重新设置

win7无法安装office2013怎么办 win7安装不了office2013如何处理

What to do if the computer can't delete the folder

Chapter 02 - Let's Get Started(C#篇)

电脑开机显示器黑屏怎么回事_开机显示器黑屏怎么解决

TypeScript 开发环境搭建
随机推荐
压缩文件如何加密码_压缩文件加密码怎么设置
笔记本电脑上有蓝牙吗 笔记本电脑如何开蓝牙
Technical analysis of development of digital currency spot contract exchange system
tiup cluster replay
how to type symbols on a computer how to type special symbols on a computer
How to handle the wireless network card of the laptop How to handle the wireless network card of the laptop
鼠标单击偶尔变双击了怎么办_电脑鼠标单击变双击了怎么设置
分布式一致性协议 之 两阶段提交协议(2PC)
戴尔灵越15pro配置 戴尔灵越15pro值得买吗
做项目,你需要。。。【持续更新】
MySQL面试必备(三)事务篇
MySQL 锁效果演示
Kotlin协程之Dispatchers原理
sudo相关漏洞CVE-2019-18634、CVE-2019-14287
使用C语言实现静态顺序表
C language - character reverse order ( gets( ) function)
System design questions interview eight-part essay recitation version
win7安全模式进不去怎么办 win7无法进入安全模式如何解决
为什么电脑打印时显示脱机_电脑打印时显示脱机怎么办
Which software is easy to use for reinstalling the system, which is the best software for reinstalling the computer system