Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
wylexample
interviewGuide
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
interviewGuide
/
docs
/
JavaJVM.md
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
50 lines (26 loc) · 2.38 KB
master
Breadcrumbs
interviewGuide
/
docs
/
JavaJVM.md
Copy path
Top
File metadata and controls
Code
Blame
50 lines (26 loc) · 2.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(
PS
:
扫描
[
首页里面的二维码
](
README
.
md
)
进群
,
分享我自己在看的技术资料给大家
,
希望和大家一起学习进步
!)
目前还只是买了最新版的
[《
深入理解JVM虚拟机
第三版
》](
backend
/
bookRecommend
?#《
深入理解Java虚拟机
-
第三版
》),
还没有完全看完
,
看完之后会从网上的面经中找一些实际的面试题
,
然后自己通过翻书查资料
,
写面试题解答
。
#### [
1.
垃圾回收有哪些特点
?](#
垃圾回收有哪些特点
?)
#### [
2.
在垃圾回收机制中
,
对象在内存中的状态有哪几种
?](#
在垃圾回收机制中
,
对象在内存中的状态有哪几种
?)
#### [
3.
对象的强引用
,
软引用
,
弱引用和虚引用的区别是什么
?](#
对象的强引用
,
软引用
,
弱引用和虚引用的区别是什么
?)
###
垃圾回收有哪些特点
?
垃圾回收具有以下特点
:
1.
只回收堆内存的对象
,
不回收其他物理资源
(
数据库连接等
)
2.
无法精准控制内存回收的时机
,
系统会在合适的时候进行内存回收
。
3.
在回收对象之前会调用对象的finalize
()
方法清理资源
,
这个方法有可能会让其他变量重新引用对象导致对象复活
。
###
在垃圾回收机制中
,
对象在内存中的状态有哪几种
?
1.
可达状态
有一个及以上的变量引用着对象
。
2.
可恢复状态
已经没有变量引用对象了
,
但是还没有被调用finalize
()
方法
。
系统在回收前会调用finalize
()
方法
,
如果在执行finalize
()
方法时
,
重新让一个变量引用了对象
,
那么对象会变成可达状态
,
否则会变成不可达状态
。
3.
不可达状态
执行finalize
()
方法后
,
对象还是被变量引用
,
那么对象就变成了不可达状态
。
###
对象的强引用
,
软引用
,
弱引用和虚引用的区别是什么
?
#####
强引用
就是普通的变量对对象的引用
,
强引用的对象不会被系统回收
。
#####
软引用
当内存空间足够时
,
软引用的对象不会被系统回收
。
当内存空间不足时
,
软引用的对象可能被系统回收
。
通常用于内存敏感的程序中
。
#####
弱引用
引用级别比软引用低
,
对于只有软引用的对象
,
不管内存是否足够
,
都可能会被系统回收
。
#####
虚引用
虚引用主要用于跟踪对象被垃圾回收的状态
,
不能单独使用
,
必须和引用队列联合使用
。
You can’t perform that action at this time.