SlideShare a Scribd company logo
#JCConf
•
•
•
•
•
•
•
•
•
•
•
•
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
•
•
•
•
#JCConf
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
https://www.youtube.com/watch?v=450maTzSIvA
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
13
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
#JCConf
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
•
–
•
•
–
•
•
–
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
A B
C
D E
F G
H
A	and	B	are	garbage	collection	roots,	
(GC	roots)
Leading	Set Retained	Set
E E,	G
C C,	D,	E,	F,	G,	H
A,	B A,	B,	C,	D,	E,	F,	G,	H
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
A B
C
D E
F G
H
A B
C
D E
F G
H
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
A B
C
D E
F G
H
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
A B
C
D E
F G
H
#JCConf
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
Done
More Things…
List	objects	→	with	outgoing	references
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
oracle.jdbc.ScrollableResultSet →	scrollStmt
→	sqlObject →	sqlBytes →	Copy	→	Value
SELECT	*	FROM	POP.PRMASTER,POP.PRITEM	 WHERE	
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
…………………………………………………..…………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
…………………………………………………………Order	 By	PRITEM.IDOCNUMBER	
DESC,PRITEM.ITEM
Merge	Shortes Paths	to	GCRoots
→	exclude	all	phantom/weak/soft	etc.	references
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
List	objects	→	with	outgoing	references
Sorting	by	Class	Name
java.lang.Thread →	org.apache.catlina.connector.Request
→	postData →	Copy	→	Value
sessionid=16F098C27D8DE1C8C7E58A15798C470A&applicantID=&hcreatorID=&
applicantName ………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
…………………………………………………………………………..…………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
…………………………………………………………………………………	 KOLON_prodhier=K0
HTTP	Request	Attributes
org.apache.catlina.connector.Request →	attributes	→	
table		→	java.util.HashMap$Entry
HTTP	Session	Data
org.apache.catlina.connector.Request →	session	→	attributes	
→	segments	→	java.util.concurrent.ConcurrentHashMap$Segment
Java	Basics	→	Thread	Overview	and	Stacks
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
•
•
•
•
•
•
•
•
#JCConf
•
–
•
–
•
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
Merge	Shortest	Paths	to	GC	Roots	
→	exclude	all	phantom/weak/soft	etc.	references
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
List	objects	→	with	outgoing	references
Expand	the	node
target	
org.apache.logging.log4j
.core.util.DefaultShutdownCallbackRegistry
Using Log4j 2 in Web Applications
You must take particular care when using Log4j or any other logging framework within a Java EE web application.
It's important for logging resources to be properly cleaned up (database connectionsclosed, files closed, etc.)
when the container shuts down or the web application is undeployed. Because of the nature of class loaders within web applications,
Log4j resources cannot be cleaned up through normalmeans. Log4j must be "started" when the web application deploys and "shut down"
when the web application undeploys. How this works varies depending on whether your application is
a Servlet 3.0 or newer or Servlet 2.5 web application.
In either case, you'll need to add the log4j-web module to your deployment as detailed in the Maven, Ivy, and Gradle Artifacts manualpage.
To avoid problems the Log4j shutdown
hook will automatically be disabled
when the log4j-web jar is included.
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
<classloader>
org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean
•
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
•
•
–
–
•
–
#JCConf
•
•
•
•
•
•
/* */ public abstract class ItemFactory
/* */ implements Constants
/* */ {
/* */ protected static Logger a;
/* 45 */ public Map b = null;
/* */ public static int c;
/* */ private static String[] A;
/* */
/* */ protected ItemFactory()
/* */ {
/* 51 */ this.b = Collections.synchronizedMap(new HashMap());
/* 52 */ if ((ItemBean.d) || (a == null)) {
/* 53 */ a = Logger.getLogger(A[2]);
/* */ }
/* */ }
Bad	news:	It	is	obfuscated	(混淆)
Can’t	decompile,	rewrite,	and	compile	…
•
public aspect ItemFactoryAop {
private final static int DEFAULT_CACHE_SIZE = 100000;
after() : execution(workflow.ItemFactory.new()) {
((ItemFactory)thisJoinPoint.getThis()).b =
Collections.synchronizedMap(
new cache.LruCache(DEFAULT_CACHE_SIZE));
}
}
•
–
•
–
•
•
#JCConf
•
•
•
•
•
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
•
•
•
–
#JCConf
•
•
•
•
#JCConf
MayYour JVM
Live Long and Prosper
生生不息、繁榮昌盛

More Related Content

PPT
Python And GIS - Beyond Modelbuilder And Pythonwin
TXT
Angle debug
PDF
Productivity tips for developers
PDF
Save JVM by Yourself: Real War Experiences of OOM
PPT
Lock Interface in Java
PDF
Java多线程技术
PDF
Nginx+tomcat https 配置
PDF
App开发过程的演变之路
Python And GIS - Beyond Modelbuilder And Pythonwin
Angle debug
Productivity tips for developers
Save JVM by Yourself: Real War Experiences of OOM
Lock Interface in Java
Java多线程技术
Nginx+tomcat https 配置
App开发过程的演变之路

Viewers also liked (15)

PDF
PPT
Recipe 黃佳伶 葉愛慧
PDF
如何更好地设计测试用例-BQConf
ODP
Building a lock profiler on the JVM
PDF
大型网站架构演变
PDF
浅谈项目管理(诸葛B2B电商研发部版改)
PPTX
Thrift+scribe实现分布式日志收集,并与log4j集成
PDF
Performance Tuning - Understanding Garbage Collection
PDF
Concurrency: Best Practices
PDF
[Java concurrency]02.basic thread synchronization
PDF
JVM及其调优
PPTX
Java concurrency - Thread pools
PDF
淺談 Java GC 原理、調教和 新發展
PDF
On heap cache vs off-heap cache
PDF
Introduction of Java GC Tuning and Java Java Mission Control
Recipe 黃佳伶 葉愛慧
如何更好地设计测试用例-BQConf
Building a lock profiler on the JVM
大型网站架构演变
浅谈项目管理(诸葛B2B电商研发部版改)
Thrift+scribe实现分布式日志收集,并与log4j集成
Performance Tuning - Understanding Garbage Collection
Concurrency: Best Practices
[Java concurrency]02.basic thread synchronization
JVM及其调优
Java concurrency - Thread pools
淺談 Java GC 原理、調教和 新發展
On heap cache vs off-heap cache
Introduction of Java GC Tuning and Java Java Mission Control
Ad

Similar to 自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015) (7)

PPT
An Introduction to JVM Internals and Garbage Collection in Java
PDF
PostgreSQL and PL/Java
PDF
Rethinking garbage collection
PDF
Rethinking garbage collection
PDF
Rails in the enterprise
PPTX
Garbage collection
PPTX
Jvm Architecture
An Introduction to JVM Internals and Garbage Collection in Java
PostgreSQL and PL/Java
Rethinking garbage collection
Rethinking garbage collection
Rails in the enterprise
Garbage collection
Jvm Architecture
Ad

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
L1 - Introduction to python Backend.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Download FL Studio Crack Latest version 2025 ?
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
assetexplorer- product-overview - presentation
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
L1 - Introduction to python Backend.pptx
CHAPTER 2 - PM Management and IT Context
Download FL Studio Crack Latest version 2025 ?
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
assetexplorer- product-overview - presentation
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Reimagine Home Health with the Power of Agentic AI​
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Monitoring Stack: Grafana, Loki & Promtail
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Computer Software and OS of computer science of grade 11.pptx
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Designing Intelligence for the Shop Floor.pdf
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Autodesk AutoCAD Crack Free Download 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf

自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)