SlideShare uma empresa Scribd logo
1 de 39
1
Does Java process memory utilization go beyond –Xmx?
2
–XX:MaxMetaspaceSize
-Xmx
Young Old
Metaspac
e
Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
Java Process Memory
3
Demo
OutOfMemoryError
4
How to know the type of OutOfMemoryError?
java.lang.OutOfMemoryError: <type>
5
Java Heap Space
Metaspac
e
Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
Most common type
6
GC Behavior of a Healthy Application
- Full Garbage Collection Event
7
GC Behavior of Acute Memory Leak
- Full Garbage Collection Event
8
GC Behavior when there is a Memory Leak
- Full Garbage Collection Event
9
How to study GC Behavior?
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<file-path>
Till Java 8
-Xlog:gc*:file=<file-path>
From Java 9
Enable GC logs (always)
Almost zero overhead
10
GCeasy
GC Log Analysis Demo
11
How to capture Heap Dumps?
8 options: https://blog.heaphero.io/2017/10/13/how-to-capture-java-heap-dumps-7-options/
1. GC Log
10. netstat
12. vmstat
2. Thread Dump
9. dmesg
3. Heap Dump
6. ps
8. Disk Usage
5. top 13. iostat
11. ping
14. Kernel Params
15. App Logs
16. metadata
4. Heap Substitute
7. top -H
12
Open-source script:
https://github.com/ycrash/yc-data-script
360° Troubleshooting artifacts
13
HeapHero
Heap Dump Analysis Demo
14
OutOfMemoryError: Java Heap Space
Causes
1. Increase in Traffic Volume
2. Memory leak due to
buggy code
Solutions
1. Fix Memory Leak in the
code
2. Increase heap size (-Xmx)
Artifacts
1. Garbage Collection Log
2. Heap Dump
Tools
1. GCeasy (GC log
analysis)
2. HeapHero
3. Eclipse MAT
4. JProfiler
15
GC overhead limit exceeded
Metaspac
e
Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
16
OutOfMemoryError: GC overhead limit exceeded
Diagnosis: Same as ‘Java Heap Space’ 
17
Requested array size exceeds VM limit
Young Old
Metaspac
e
Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
18
Demo
OutOfMemoryError: Requested array size exceeds VM
limit
19
OutOfMemoryError: Requested array size exceeds VM limit
Causes
1. Allocated array larger than
heap size
Solutions
1. Fix Memory Leak code
2. Increase heap size (-Xmx)
Artifacts
1. Application Log or std error
Tools
20
Metaspace
Young Old Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
21
Demo
OutOfMemoryError: Metaspace
22
Metaspace Memory Leak
- Full Garbage Collection Event
23
OutOfMemoryError: Metaspace
Causes
1. Creating large number of
Dynamic classes (Java
Reflection, Groovy type of script
languages)
2. Loading large number of Classes
3. Loading large number of
Classloaders
Solutions
1. Fix Memory Leak code
2. Increase -XX:MetaspaceSize
and
-XX:MaxMetaspaceSize.
Artifacts
1. Java 8 & below: java
{app_name} -verbose:class
2. Java 9 & above: java
{app_name} -
Xlog:class+load=info:<filena
me>
3. jcmd {pid} GC.class_histogram
4. Heap Dump
Tools
1. Gceasy (GC log analysis)
2. HeapHero
3. Eclipse MAT
4. JProfiler
5. JHat
24
Permgen space
Young Old Threads JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
Happens only in Java 7 & below
25
OutOfMemoryError: Permgen Space
Diagnosis: Same as ‘Metaspace’ 
26
Unable to create new native threads
Young Old
Metaspac
e
JNI misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
27
Real Case Study
Slowdown in a Major Financial Institution’s Middleware
http://fastthread.io/my-thread-report.jsp?p=c2hhcmVkLzIwMTcvMDMvMTQvLS10aHJlYWREdW1wLTIudHh0LS0xMi0yOC0zMw==&s=t
28
OutOfMemoryError: Unable to create new native
threads
Causes
1. Threads are leaking
Solutions
1. Fix thread leak
2. Increase the Thread Limits Set
at Operating System(ulimit –u)
3. Reduce Java Heap Size
4. Kills other processes
5. Increase RAM capacity
6. Reduce thread stack size (-Xss).
Note: can cause
Artifacts
1. Thread Dump
Tools
1. FastThread
2. Text Editor
29
Direct buffer memory
Young Old
Metaspac
e
Threads JNI misc
GC
Code
Cach
e
Heap Memory Native Memory
JVM Memory
Becoming Prevasive in modern Spring Boot Frameworks
30
OutOfMemoryError: Direct buffer memory
Causes
1. Increase(or Leak) in direct buffers
usage
a. java.nio package
b. Moving from Spring
RestTemplate to WebClient
c. Image Processing Libraries
d. Networking Libraries
e. Some JDBC Drives
Solutions
1. Fix Memory Leak code
2. Increase -
XX:MaxDirectMemorySize
3. Upgrade to Java 17 (There some
issues in Java 11)
Artifacts
1. App Log or Std error
2. Native Memory Tracking
Tools
31
Kill process or sacrifice child
JVM Kernel
X
32
Real Case Study
Intermittent HTTP 502 errors in AWS EBS Service
EBS Architecture
33
Clue: Nginx Error
34
35
36
OutOfMemoryError: Kill process or sacrifice child
Causes
1. Lack of RAM capacity
2. High Memory utilization by
other processes
3. Memory Leak in the code
Solutions
1. Kill other processes
2. Increase RAM capacity
3. Fix Memory Leak in the code
Artifacts
1. Dmesg
2. GC Log
3. Heap Dump
4. Native Memory Tracking
Tools
1. HeapHero
2. Eclipse MAT
3. yCrash
37
Reason stack_trace_with_native_method
Young Old
Metaspac
e
Threads misc
GC
Direct
Buff
Code
Cach
e
Heap Memory Native Memory
JVM Memory
38
OutOfMemoryError: Reason stack_trace_with_native_method
Don’t worry, if you are not using JNI 
Ram Lakshmanan ram@tier1app.com
@tier1app https://www.linkedin.com/company/ycrash
This deck will be published in:
https://blog.heaphero.io
If you want to learn more …
39
THANK YOU
FRIENDS

Mais conteúdo relacionado

Semelhante a Effectively Troubleshoot 9 Types of OutOfMemoryError

Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsPhillip Koza
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Jean-Philippe BEMPEL
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1 App
 
Shooting the troubles: Crashes, Slowdowns, CPU Spikes
Shooting the troubles: Crashes, Slowdowns, CPU SpikesShooting the troubles: Crashes, Slowdowns, CPU Spikes
Shooting the troubles: Crashes, Slowdowns, CPU SpikesTier1 app
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUGJorge Morales
 
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Ontico
 
java-monitoring-troubleshooting
java-monitoring-troubleshootingjava-monitoring-troubleshooting
java-monitoring-troubleshootingWilliam Au
 
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey SerebryanskiyWhat to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey SerebryanskiyHostedbyConfluent
 
JBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingJBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingAlexandre Cavalcanti
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlLeon Chen
 
16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problemTier1 app
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problemsTier1 app
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1상욱 송
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and opsaragozin
 

Semelhante a Effectively Troubleshoot 9 Types of OutOfMemoryError (20)

Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applications
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Javasession10
Javasession10Javasession10
Javasession10
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Shooting the troubles: Crashes, Slowdowns, CPU Spikes
Shooting the troubles: Crashes, Slowdowns, CPU SpikesShooting the troubles: Crashes, Slowdowns, CPU Spikes
Shooting the troubles: Crashes, Slowdowns, CPU Spikes
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
 
[BGOUG] Java GC - Friend or Foe
[BGOUG] Java GC - Friend or Foe[BGOUG] Java GC - Friend or Foe
[BGOUG] Java GC - Friend or Foe
 
java-monitoring-troubleshooting
java-monitoring-troubleshootingjava-monitoring-troubleshooting
java-monitoring-troubleshooting
 
Cache is King
Cache is KingCache is King
Cache is King
 
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey SerebryanskiyWhat to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
What to do if Your Kafka Streams App Gets OOMKilled? with Andrey Serebryanskiy
 
JBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 TroubleshootingJBoss Enterprise Application Platform 6 Troubleshooting
JBoss Enterprise Application Platform 6 Troubleshooting
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
 
16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem16 artifacts to capture when there is a production problem
16 artifacts to capture when there is a production problem
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 
Inside the jvm
Inside the jvmInside the jvm
Inside the jvm
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
Java on Linux for devs and ops
Java on Linux for devs and opsJava on Linux for devs and ops
Java on Linux for devs and ops
 

Mais de Tier1 app

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
Top-5-java-perf-problems-jax_mainz_2024.pptx
Top-5-java-perf-problems-jax_mainz_2024.pptxTop-5-java-perf-problems-jax_mainz_2024.pptx
Top-5-java-perf-problems-jax_mainz_2024.pptxTier1 app
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
 
predicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptxTier1 app
 
Top-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptxTier1 app
 
predicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptxTier1 app
 
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...Tier1 app
 
7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptxTier1 app
 
Top-5-Performance-JaxLondon-2023.pptx
Top-5-Performance-JaxLondon-2023.pptxTop-5-Performance-JaxLondon-2023.pptx
Top-5-Performance-JaxLondon-2023.pptxTier1 app
 
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLETier1 app
 
MAJOR OUTAGES IN MAJOR ENTERPRISES
MAJOR OUTAGES IN MAJOR ENTERPRISESMAJOR OUTAGES IN MAJOR ENTERPRISES
MAJOR OUTAGES IN MAJOR ENTERPRISESTier1 app
 
KnowAPIs-UnknownPerf-confoo-2023 (1).pptx
KnowAPIs-UnknownPerf-confoo-2023 (1).pptxKnowAPIs-UnknownPerf-confoo-2023 (1).pptx
KnowAPIs-UnknownPerf-confoo-2023 (1).pptxTier1 app
 
memory-patterns-confoo-2023.pptx
memory-patterns-confoo-2023.pptxmemory-patterns-confoo-2023.pptx
memory-patterns-confoo-2023.pptxTier1 app
 
this-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxthis-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxTier1 app
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxTier1 app
 
lets-crash-apps-jax-2022.pptx
lets-crash-apps-jax-2022.pptxlets-crash-apps-jax-2022.pptx
lets-crash-apps-jax-2022.pptxTier1 app
 
‘16 artifacts’ to capture when there is a production problem
‘16 artifacts’ to capture when there is a production problem‘16 artifacts’ to capture when there is a production problem
‘16 artifacts’ to capture when there is a production problemTier1 app
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applicationsTier1 app
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applicationsTier1 app
 

Mais de Tier1 app (20)

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Top-5-java-perf-problems-jax_mainz_2024.pptx
Top-5-java-perf-problems-jax_mainz_2024.pptxTop-5-java-perf-problems-jax_mainz_2024.pptx
Top-5-java-perf-problems-jax_mainz_2024.pptx
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
 
predicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
 
Top-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
 
predicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
 
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...
Predicting Production Outages: Unleashing the Power of Micro-Metrics – ADDO C...
 
7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx7-JVM-arguments-JaxLondon-2023.pptx
7-JVM-arguments-JaxLondon-2023.pptx
 
Top-5-Performance-JaxLondon-2023.pptx
Top-5-Performance-JaxLondon-2023.pptxTop-5-Performance-JaxLondon-2023.pptx
Top-5-Performance-JaxLondon-2023.pptx
 
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
 
MAJOR OUTAGES IN MAJOR ENTERPRISES
MAJOR OUTAGES IN MAJOR ENTERPRISESMAJOR OUTAGES IN MAJOR ENTERPRISES
MAJOR OUTAGES IN MAJOR ENTERPRISES
 
KnowAPIs-UnknownPerf-confoo-2023 (1).pptx
KnowAPIs-UnknownPerf-confoo-2023 (1).pptxKnowAPIs-UnknownPerf-confoo-2023 (1).pptx
KnowAPIs-UnknownPerf-confoo-2023 (1).pptx
 
memory-patterns-confoo-2023.pptx
memory-patterns-confoo-2023.pptxmemory-patterns-confoo-2023.pptx
memory-patterns-confoo-2023.pptx
 
this-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxthis-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptx
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptx
 
lets-crash-apps-jax-2022.pptx
lets-crash-apps-jax-2022.pptxlets-crash-apps-jax-2022.pptx
lets-crash-apps-jax-2022.pptx
 
‘16 artifacts’ to capture when there is a production problem
‘16 artifacts’ to capture when there is a production problem‘16 artifacts’ to capture when there is a production problem
‘16 artifacts’ to capture when there is a production problem
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 
Lets crash-applications
Lets crash-applicationsLets crash-applications
Lets crash-applications
 

Último

IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersEmilyJiang23
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdfkalichargn70th171
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfsteffenkarlsson2
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 

Último (20)

AI Hackathon.pptx
AI                        Hackathon.pptxAI                        Hackathon.pptx
AI Hackathon.pptx
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 

Effectively Troubleshoot 9 Types of OutOfMemoryError

  • 1. 1
  • 2. Does Java process memory utilization go beyond –Xmx? 2 –XX:MaxMetaspaceSize -Xmx Young Old Metaspac e Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory Java Process Memory
  • 4. 4 How to know the type of OutOfMemoryError? java.lang.OutOfMemoryError: <type>
  • 5. 5 Java Heap Space Metaspac e Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory Most common type
  • 6. 6 GC Behavior of a Healthy Application - Full Garbage Collection Event
  • 7. 7 GC Behavior of Acute Memory Leak - Full Garbage Collection Event
  • 8. 8 GC Behavior when there is a Memory Leak - Full Garbage Collection Event
  • 9. 9 How to study GC Behavior? -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<file-path> Till Java 8 -Xlog:gc*:file=<file-path> From Java 9 Enable GC logs (always) Almost zero overhead
  • 11. 11 How to capture Heap Dumps? 8 options: https://blog.heaphero.io/2017/10/13/how-to-capture-java-heap-dumps-7-options/
  • 12. 1. GC Log 10. netstat 12. vmstat 2. Thread Dump 9. dmesg 3. Heap Dump 6. ps 8. Disk Usage 5. top 13. iostat 11. ping 14. Kernel Params 15. App Logs 16. metadata 4. Heap Substitute 7. top -H 12 Open-source script: https://github.com/ycrash/yc-data-script 360° Troubleshooting artifacts
  • 14. 14 OutOfMemoryError: Java Heap Space Causes 1. Increase in Traffic Volume 2. Memory leak due to buggy code Solutions 1. Fix Memory Leak in the code 2. Increase heap size (-Xmx) Artifacts 1. Garbage Collection Log 2. Heap Dump Tools 1. GCeasy (GC log analysis) 2. HeapHero 3. Eclipse MAT 4. JProfiler
  • 15. 15 GC overhead limit exceeded Metaspac e Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory
  • 16. 16 OutOfMemoryError: GC overhead limit exceeded Diagnosis: Same as ‘Java Heap Space’ 
  • 17. 17 Requested array size exceeds VM limit Young Old Metaspac e Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory
  • 19. 19 OutOfMemoryError: Requested array size exceeds VM limit Causes 1. Allocated array larger than heap size Solutions 1. Fix Memory Leak code 2. Increase heap size (-Xmx) Artifacts 1. Application Log or std error Tools
  • 20. 20 Metaspace Young Old Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory
  • 22. 22 Metaspace Memory Leak - Full Garbage Collection Event
  • 23. 23 OutOfMemoryError: Metaspace Causes 1. Creating large number of Dynamic classes (Java Reflection, Groovy type of script languages) 2. Loading large number of Classes 3. Loading large number of Classloaders Solutions 1. Fix Memory Leak code 2. Increase -XX:MetaspaceSize and -XX:MaxMetaspaceSize. Artifacts 1. Java 8 & below: java {app_name} -verbose:class 2. Java 9 & above: java {app_name} - Xlog:class+load=info:<filena me> 3. jcmd {pid} GC.class_histogram 4. Heap Dump Tools 1. Gceasy (GC log analysis) 2. HeapHero 3. Eclipse MAT 4. JProfiler 5. JHat
  • 24. 24 Permgen space Young Old Threads JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory Happens only in Java 7 & below
  • 25. 25 OutOfMemoryError: Permgen Space Diagnosis: Same as ‘Metaspace’ 
  • 26. 26 Unable to create new native threads Young Old Metaspac e JNI misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory
  • 27. 27 Real Case Study Slowdown in a Major Financial Institution’s Middleware http://fastthread.io/my-thread-report.jsp?p=c2hhcmVkLzIwMTcvMDMvMTQvLS10aHJlYWREdW1wLTIudHh0LS0xMi0yOC0zMw==&s=t
  • 28. 28 OutOfMemoryError: Unable to create new native threads Causes 1. Threads are leaking Solutions 1. Fix thread leak 2. Increase the Thread Limits Set at Operating System(ulimit –u) 3. Reduce Java Heap Size 4. Kills other processes 5. Increase RAM capacity 6. Reduce thread stack size (-Xss). Note: can cause Artifacts 1. Thread Dump Tools 1. FastThread 2. Text Editor
  • 29. 29 Direct buffer memory Young Old Metaspac e Threads JNI misc GC Code Cach e Heap Memory Native Memory JVM Memory Becoming Prevasive in modern Spring Boot Frameworks
  • 30. 30 OutOfMemoryError: Direct buffer memory Causes 1. Increase(or Leak) in direct buffers usage a. java.nio package b. Moving from Spring RestTemplate to WebClient c. Image Processing Libraries d. Networking Libraries e. Some JDBC Drives Solutions 1. Fix Memory Leak code 2. Increase - XX:MaxDirectMemorySize 3. Upgrade to Java 17 (There some issues in Java 11) Artifacts 1. App Log or Std error 2. Native Memory Tracking Tools
  • 31. 31 Kill process or sacrifice child JVM Kernel X
  • 32. 32 Real Case Study Intermittent HTTP 502 errors in AWS EBS Service
  • 35. 35
  • 36. 36 OutOfMemoryError: Kill process or sacrifice child Causes 1. Lack of RAM capacity 2. High Memory utilization by other processes 3. Memory Leak in the code Solutions 1. Kill other processes 2. Increase RAM capacity 3. Fix Memory Leak in the code Artifacts 1. Dmesg 2. GC Log 3. Heap Dump 4. Native Memory Tracking Tools 1. HeapHero 2. Eclipse MAT 3. yCrash
  • 37. 37 Reason stack_trace_with_native_method Young Old Metaspac e Threads misc GC Direct Buff Code Cach e Heap Memory Native Memory JVM Memory
  • 39. Ram Lakshmanan ram@tier1app.com @tier1app https://www.linkedin.com/company/ycrash This deck will be published in: https://blog.heaphero.io If you want to learn more … 39 THANK YOU FRIENDS

Notas do Editor

  1. Eclipse: LaunchPad_oom
  2. Gceasy - C:\workspace\ycrash\speeches\9-types-oom\memory-leak.log
  3. https://blog.heaphero.io/2017/10/13/how-to-capture-java-heap-dumps-7-options/
  4. http://localhost:8080/heap-index.jsp C:\workspace\tmp\dev-nexus\dump-2024-04-09.hprof http://localhost:8080/heap-report-wc.jsp?p=ZDI0ZHIxRGJtaUhHQXN3eUFWa3htQW9QeERicTZpZjNUczlXTFVVTE9jcWpMeHBsRkpSZEV4Vkk5cDZqZHJIK2NzditQeWx0UDZDbUhmNEIySTBZMkZ6NUhjMkh3SFdOSUdPZU5WTHZHZlk2dEdnQnNCMmp2MkltMEdoUnFxcUY=
  5. OOMRequestedArraySizeExceedsVMLimit
  6. com.buggyapp.oom.RequestedArraySizeExceedsVMLimit
  7. OOMMetaspace OOMMetaspace_verbose
  8. C:\workspace\ycrash\speeches\9-types-oom\thread-leak.txt Backup: http://localhost:8080/yc-report.jsp?ou=SAP&de=127.0.0.1&app=yc&ts=2024-04-09T11-09-51
  9. http://localhost:8080/yc-report.jsp?ou=SAP&de=10.160.1.221&app=yc&ts=2024-04-02T09-59-41
  10. https://test.ycrash.io/yc-report-kernel.jsp?ou=czlWbG0rUko0UXAxazlSbjZrSUIwUT09&de=172.31.7.106&app=yc&ts=2023-09-01T10-25-39