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 }}
Teemo-Java
Teemo-Java-technology_study
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Teemo-Java-technology_study
/
test
/
src
/
A71_80.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
74 lines (35 loc) · 1.89 KB
master
Breadcrumbs
Teemo-Java-technology_study
/
test
/
src
/
A71_80.java
Copy path
Top
File metadata and controls
Code
Blame
74 lines (35 loc) · 1.89 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
public
class
A71_80
{
/* 71 OOM介绍
out of memory(OOM) :内存溢出,指程序无法再申请到足够的内存
memory leak :内存泄露,指程序无法释放自己申请的内存,内存泄露多次后 会导致OOM
*/
/*
72 发生OOM的区域
1 metaspace(元空间,永久代),这块内存用于存储类信息的,当加载的类越来越多 这里是有可能发生OOM的
2 虚拟机栈,虚拟机栈一般设置了1M,用于存储局部变量等等,这里也是有可能发生OOM的
3 堆内存,这里肯定有可能OOM的
*/
/*
73 metaspace溢出
元空间溢出会触发Full GC,其溢出的情况主要有两种
1 未设置元空间内存大小,默认的元空间大小才几十M,如果系统比较复杂,各种引用jar,就有可能放不下。 从参数 -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m 设置元空间
2 程序员在写代码的时候动态生成类(比如cglib),如果代码没控制好,有可能生成的类过多,造成元空间OOM
*/
/* 74 栈溢出
每一个线程对对应一个虚拟机栈,这个栈的大小一般就设置为1M,用于存储局部变量等信息
比如:下面执行后,就是main线程,首先把main方法栈帧压入栈内,然后把test方法栈帧,test方法执行完之后,其方法内的变量销毁,栈帧出栈
一般来说就算栈内存只有128K 也基本足够了,如果栈溢出,那基本就是代码有bug了。
比如下面的test1()方法,无限递归调用,这里因为栈帧是占用一定大小的(即使是空方法),所以就发生StackOverflowError
*/
public
static
void
main
(
String
[]
args
) {
// test();
test1
();
}
public
static
void
test
(){
String
msg
=
"test"
;
System
.
out
.
println
(
msg
);
}
public
static
void
test1
(){
test1
();
}
}
You can’t perform that action at this time.