O'Reilly logo
live online training icon Live Online training

Solving Java Memory Leaks

OOME be gone

Kirk Pepperdine

One of the more important aspects of the Java Virtual Machine (JVM) is it’s managed memory subsystem. It’s an amazing piece of technology in that it allows developers to allocate a seemingly infinite amount of memory. The reality is that under the covers, the JVM is working on reclaiming all memory that is no longer in use. If the JVM is unable to recover memory, our application will fail with a dreaded OutOfMemoryError.

This workshop will cover several common scenarios that can cause the JVM to fail with an OutOfMemoryError. We’ll explore tooling and methods that can be used to diagnose the cause of an OutOfMemoryError. Finally, this is a workshop meaning you’ll go toe to toe with several applications that are failing with an OutOfMemoryError. Topics that will be covered include; 1. Overview of Java heap 2. Allocations in Java heap 3. GC basics with Mark and Sweep 4. Normal life cycle of a Java object 5. Common causes of OutOfMemoryError 6. Anatomy of a memory leak 7. Tools for detecting memory leaks

What you'll learn-and how you can apply it

  • Identify the difference between memory leaks in native, class loader and Java heap
  • Common causes of memory leaks in Java heap
  • The role of the Garbage collector in memory leaks
  • Anatomy of a memory leak
  • Common causes of memory leaks
  • Recipes and tools to characterize memory leaks

This training course is for you because...

  • You are a Java developer looking to broaden your skills
  • You are looking for better ways to solve OutOfMemoryErrors

Prerequisites

  • Java developers, operations and testers with a least 1 years experience with java

Course Set-up

About your instructor

  • Kirk has been performance tuning Java applications for over 20 years. Frequent speaker at JUGs and conferences worldwide and has been named a JavaONE rockstar numerous times. Kirk authored the original Java performance tuning workshop and jPDM, a performance diagnostic model. This model is the core of the diagnostic engine developed by JClarity, a startup cofounded by Kirk.

    In 2006 Kirk was named as a Java Champion. More recently he has named as part of the Oracle groundbreakers and InfoQ influencers. Kirk continues to be an ardent support of the Java community cofounding JCrete, a Java unconference and by helping other establish Java (un)conferences worldwide.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Section 1 - Introduction (90 minutes)

  • Managed and unmanaged memory
  • Structure of Java heap
  • Monitoring Java heap with live demo
  • Allocations in Java heap
  • Garbage collection cycle
  • Memory leak characterized
  • Anatomy of a leak

Section 2 - Generational Counts (45 minutes)

  • Recipe for characterization of memory leaks using generational counts
  • Demonstration of recipe
  • Memory leak exercise 1
  • Review exercise 1

Section 3 - Dominator Trees (45 minutes)

  • Recipe for characterization of memory leaks using Dominator trees
  • Demonstration of recipe
  • Memory leak exercise 2
  • Review exercise 2

Section 4 - Class Loader Leaks (45 minutes)

  • Classloader basics
  • Classloader leaks
  • Recipe for characterization of Classloader leaks
  • Memory leak exercise 3
  • Review exercise 3

Section 5 – Wrap-up (15 minutes)

  • Further questions