SlideShare a Scribd company logo
Out Of Memory
 Analyze Your Java Heap
GC silver bullet


•   Unreferenced memory cleared

    Fragmentation cleanup



    Incorrect understanding of data / structures
•   Packratting
Data / Structures

•   Primitives vs Objects

        Byte vs byte
•   Overhead of structure
    •   LinkedList vs ArrayList

    JVM settings
    •   UseCompressedOops, UseCompressedStrings
Packratting

•   Unintentionally storing data

        Unbounded caches
    •   Classloaders
    •   Containers / plugins

        ThreadLocals
    •   Statics
What now




Avoid situation ;-)
Snapshot


•   -XX:+HeapDumpOnCtrlBreak

    -XX:+HeapDumpOnOutOfMemoryError

    jmap -dump:format=b,file=snapshot.bin pid
•   jconsole
Javaforum   looking into the memory
MAT
              Eclipse Memory Analyzer
              Eclipse Memory Analyzer




•   Wizards

    Compare
•   Explore

    Query
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Javaforum   looking into the memory
Watch out



•   Can be large

    Takes time to produce
•   Can contain sensitive information
LInks

    MAT http://www.eclipse.org/mat/

    jconsole
    http://docs.oracle.com/javase/7/docs/technotes/tools/share/jconsole.html

    jmap
    http://docs.oracle.com/javase/7/docs/technotes/tools/share/jmap.html

    jstat
    http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html

•   Java API http://www.eclipse.org/forums/index.php/t/243401/

More Related Content

PDF
Hp java heap dump analysis Workshop
PPT
Heap & thread dump
PDF
Thread Dump Analysis
PDF
Java Heap Dump Analysis Primer
PDF
java-monitoring-troubleshooting
PPTX
Taming the resource tiger
PDF
Casual mass parallel data processing in Java
PPTX
DIY Java Profiling
Hp java heap dump analysis Workshop
Heap & thread dump
Thread Dump Analysis
Java Heap Dump Analysis Primer
java-monitoring-troubleshooting
Taming the resource tiger
Casual mass parallel data processing in Java
DIY Java Profiling

What's hot (20)

PDF
Alto Desempenho com Java
PPTX
The architecture of oak
PPT
Solr Performance Monitoring with SPM
PPT
Cluster your application using CDI and JCache - Jonathan Gallimore
PDF
Debugging Your Production JVM
PPTX
Creating a Benchmarking Infrastructure That Just Works
PDF
Sly and the RoarVM: Exploring the Manycore Future of Programming
PDF
Cassandra Redis
PDF
JCR - Java Content Repositories
PDF
Hive at booking
PPT
Large Scale Log collection using LogStash & mongoDB
PPTX
PostgreSQL Terminology
PDF
SQL for Elasticsearch
PPT
JavaScript Event Loop
PDF
Turning a Search Engine into a Relational Database
PDF
Java Memory Descreption
PDF
Web Crawling with Apache Nutch
PPTX
Java variables and classes
PPTX
HotSpotコトハジメ
PDF
Lightweight Grids With Terracotta
Alto Desempenho com Java
The architecture of oak
Solr Performance Monitoring with SPM
Cluster your application using CDI and JCache - Jonathan Gallimore
Debugging Your Production JVM
Creating a Benchmarking Infrastructure That Just Works
Sly and the RoarVM: Exploring the Manycore Future of Programming
Cassandra Redis
JCR - Java Content Repositories
Hive at booking
Large Scale Log collection using LogStash & mongoDB
PostgreSQL Terminology
SQL for Elasticsearch
JavaScript Event Loop
Turning a Search Engine into a Relational Database
Java Memory Descreption
Web Crawling with Apache Nutch
Java variables and classes
HotSpotコトハジメ
Lightweight Grids With Terracotta
Ad

Similar to Javaforum looking into the memory (20)

PDF
Cache is King ( Or How To Stop Worrying And Start Caching in Java) at Chicago...
KEY
Memcached: What is it and what does it do?
PPTX
SeaJUG May 2012 mybatis
PPT
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
PPTX
Bigdata antipatterns
PPTX
How to Actually Tune Your Spark Jobs So They Work
PPTX
Application Profiling for Memory and Performance
PDF
Where Django Caching Bust at the Seams
PPTX
Javasession10
PDF
Scalability, Availability & Stability Patterns
KEY
Big Search with Big Data Principles
ODP
Jvm tuning in a rush! - Lviv JUG
PDF
Understanding Memory Management In Spark For Fun And Profit
PDF
Fabian Hueske – Juggling with Bits and Bytes
PDF
WebObjects Optimization
PDF
Unsafe Java
PDF
Application Profiling for Memory and Performance
PDF
Distributed applications using Hazelcast
PPTX
Composable Futures with Akka 2.0
PPTX
Exploring Java Heap Dumps (Oracle Code One 2018)
Cache is King ( Or How To Stop Worrying And Start Caching in Java) at Chicago...
Memcached: What is it and what does it do?
SeaJUG May 2012 mybatis
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
Bigdata antipatterns
How to Actually Tune Your Spark Jobs So They Work
Application Profiling for Memory and Performance
Where Django Caching Bust at the Seams
Javasession10
Scalability, Availability & Stability Patterns
Big Search with Big Data Principles
Jvm tuning in a rush! - Lviv JUG
Understanding Memory Management In Spark For Fun And Profit
Fabian Hueske – Juggling with Bits and Bytes
WebObjects Optimization
Unsafe Java
Application Profiling for Memory and Performance
Distributed applications using Hazelcast
Composable Futures with Akka 2.0
Exploring Java Heap Dumps (Oracle Code One 2018)
Ad

More from Squeed (9)

PDF
Liquibase få kontroll på dina databasförändringar
PDF
Efficient Code Organisation
PDF
Groovy moppingjavaforum
PDF
Refactoring toward deeper insight java forum
PDF
Personal kaizen
PDF
Java one 2011_v0.9
PDF
Javaforum coin
PDF
Javaforum indy
PDF
Javaforum 20110915
Liquibase få kontroll på dina databasförändringar
Efficient Code Organisation
Groovy moppingjavaforum
Refactoring toward deeper insight java forum
Personal kaizen
Java one 2011_v0.9
Javaforum coin
Javaforum indy
Javaforum 20110915

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
cuic standard and advanced reporting.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Spectroscopy.pptx food analysis technology
cuic standard and advanced reporting.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I

Javaforum looking into the memory

  • 1. Out Of Memory Analyze Your Java Heap
  • 2. GC silver bullet • Unreferenced memory cleared Fragmentation cleanup Incorrect understanding of data / structures • Packratting
  • 3. Data / Structures • Primitives vs Objects Byte vs byte • Overhead of structure • LinkedList vs ArrayList JVM settings • UseCompressedOops, UseCompressedStrings
  • 4. Packratting • Unintentionally storing data Unbounded caches • Classloaders • Containers / plugins ThreadLocals • Statics
  • 6. Snapshot • -XX:+HeapDumpOnCtrlBreak -XX:+HeapDumpOnOutOfMemoryError jmap -dump:format=b,file=snapshot.bin pid • jconsole
  • 8. MAT Eclipse Memory Analyzer Eclipse Memory Analyzer • Wizards Compare • Explore Query
  • 26. Watch out • Can be large Takes time to produce • Can contain sensitive information
  • 27. LInks MAT http://www.eclipse.org/mat/ jconsole http://docs.oracle.com/javase/7/docs/technotes/tools/share/jconsole.html jmap http://docs.oracle.com/javase/7/docs/technotes/tools/share/jmap.html jstat http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html • Java API http://www.eclipse.org/forums/index.php/t/243401/

Editor's Notes

  • #3: The data we need might be larger than we realize Storing too much intentionally (Caches) Storing too much unintentionally (forgetting to dereference)
  • #4: Primitive types vs objects Referencing same object vs a copy Integer.valueOf...
  • #7: Generate a snapshot by sending signal, automatically from keyboard or different external programs.
  • #8: Sample program which tries to store short strings by doing substring on large strings (which actually uses the same large char array as the large string.
  • #9: Different aspects of using MAT
  • #10: Open a snapshot
  • #11: Store each snapshot in a separate folder since opening it in MAT will create several index files used by MAT and will soon clutter up a folder with several snapshots.
  • #12: Opening can take some time (indexes are generated)
  • #13: After startup dirrerent reports can automatically be run.
  • #14: MAT shows if a few objects are holding on to most of the memory and makes them suspects.
  • #15: Generate class histograms from the histogram button.
  • #16: You can now see the number of objects, their shallow heap (memory by the object itself) and retained heap (memory by objects referenced, such as lists, maps etc)
  • #17: To the left info about the class / instance can be seen
  • #18: Show instances of this class with instances pointing to it.
  • #20: Filter histogram with regexp
  • #21: Show instances with what it points to
  • #22: StoreLargeString is small, but references a List which is large, has an array of 1000000 elements, and 1000000 strings, each referencing an array of 26KB
  • #24: Select previous searches into compare basket
  • #25: Compare and you can see actual values or differences between queries
  • #26: With OQL you can select objects from their type and member values
  • #27: Handle the snapshots with care, they can contain sensitive information
  • #28: Links. The Java API mainly points to discussion of how to use.