SlideShare a Scribd company logo
1 of 27
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
MAT
              Eclipse Memory Analyzer
              Eclipse Memory Analyzer




•   Wizards

    Compare
•   Explore

    Query
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

What's hot

Alto Desempenho com Java
Alto Desempenho com JavaAlto Desempenho com Java
Alto Desempenho com Java
codebits
 
Sly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of ProgrammingSly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of Programming
Stefan Marr
 

What's hot (20)

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

Similar to Javaforum looking into the memory

SeaJUG May 2012 mybatis
SeaJUG May 2012 mybatisSeaJUG May 2012 mybatis
SeaJUG May 2012 mybatis
Will Iverson
 
WebObjects Optimization
WebObjects OptimizationWebObjects Optimization
WebObjects Optimization
WO Community
 
Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
WSO2
 

Similar to Javaforum looking into the memory (20)

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

More from Squeed

More from Squeed (9)

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

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

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
  • 7.
  • 8. MAT Eclipse Memory Analyzer Eclipse Memory Analyzer • Wizards Compare • Explore Query
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 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

  1. The data we need might be larger than we realize Storing too much intentionally (Caches) Storing too much unintentionally (forgetting to dereference)
  2. Primitive types vs objects Referencing same object vs a copy Integer.valueOf...
  3. Generate a snapshot by sending signal, automatically from keyboard or different external programs.
  4. 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.
  5. Different aspects of using MAT
  6. Open a snapshot
  7. 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.
  8. Opening can take some time (indexes are generated)
  9. After startup dirrerent reports can automatically be run.
  10. MAT shows if a few objects are holding on to most of the memory and makes them suspects.
  11. Generate class histograms from the histogram button.
  12. 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)
  13. To the left info about the class / instance can be seen
  14. Show instances of this class with instances pointing to it.
  15. Filter histogram with regexp
  16. Show instances with what it points to
  17. 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
  18. Select previous searches into compare basket
  19. Compare and you can see actual values or differences between queries
  20. With OQL you can select objects from their type and member values
  21. Handle the snapshots with care, they can contain sensitive information
  22. Links. The Java API mainly points to discussion of how to use.