Lesson 2 Dissecting Memory Problems

Similar documents
Troubleshooting Memory Problems in Java Applications

JVM Troubleshooting MOOC: Troubleshooting Memory Issues in Java Applications

Lesson 3 Diagnostic Data Collection and Analysis tools

Java Memory Management. Märt Bakhoff Java Fundamentals

10/26/2017 Universal Java GC analysis tool - Java Garbage collection log analysis made easy

It s Good to Have (JVM) Options

JVM Memory Model and GC

Habanero Extreme Scale Software Research Project

MEMORY MANAGEMENT HEAP, STACK AND GARBAGE COLLECTION

Exploiting the Behavior of Generational Garbage Collector

Do Your GC Logs Speak To You

Unified JVM Logging in JDK 9

Chapter 4 Java Language Fundamentals

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

Typical Issues with Middleware

Java Performance Tuning

Welcome to the session...

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

Managed runtimes & garbage collection

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

StackVsHeap SPL/2010 SPL/20

Java Performance: The Definitive Guide

JDK 9/10/11 and Garbage Collection

Java Performance Tuning From A Garbage Collection Perspective. Nagendra Nagarajayya MDE

PARAMETERS Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.

G1 Garbage Collector Details and Tuning. Simone Bordet

Java Garbage Collection. Carol McDonald Java Architect Sun Microsystems, Inc.

A NEW PLATFORM FOR A NEW ERA. Copyright 2014 Pivotal. All rights reserved.

CS 345. Garbage Collection. Vitaly Shmatikov. slide 1

OS-caused Long JVM Pauses - Deep Dive and Solutions

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)

Using Automated Network Management at Fiserv. June 2012

THE TROUBLE WITH MEMORY

Heap Compression for Memory-Constrained Java

The Z Garbage Collector Scalable Low-Latency GC in JDK 11

20 Most Important Java Programming Interview Questions. Powered by

Java Performance Tuning and Optimization Student Guide

JAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder

Webcenter Application Performance Tuning guide

Attila Szegedi, Software

The Fundamentals of JVM Tuning

High-Level Language VMs

Java performance - not so scary after all

Memory management has always involved tradeoffs between numerous optimization possibilities: Schemes to manage problem fall into roughly two camps

The G1 GC in JDK 9. Erik Duveblad Senior Member of Technical Staf Oracle JVM GC Team October, 2017

Garbage Collection. Hwansoo Han

Garbage Collection. Steven R. Bagley

Garbage Collection. Akim D le, Etienne Renault, Roland Levillain. May 15, CCMP2 Garbage Collection May 15, / 35

Practical Lessons in Memory Analysis

How to keep capacity predictions on target and cut CPU usage by 5x

Shenandoah An ultra-low pause time Garbage Collector for OpenJDK. Christine H. Flood Roman Kennke

2011 Oracle Corporation and Affiliates. Do not re-distribute!

JVM Performance Study Comparing Java HotSpot to Azul Zing Using Red Hat JBoss Data Grid

Virtualizing JBoss Enterprise Middleware with Azul

Heckaton. SQL Server's Memory Optimized OLTP Engine

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

New Java performance developments: compilation and garbage collection

The Impact of a Real-Time JVM on Middleware Performance: Lessons Learned from Implementing DDS on IBM s J9

J Optimizer 1.0 User Guide

Oracle JRockit E

Java Internals. Frank Yellin Tim Lindholm JavaSoft

NUMA in High-Level Languages. Patrick Siegler Non-Uniform Memory Architectures Hasso-Plattner-Institut

Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide. Release 10

Lecture 15 Garbage Collection

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides

Zing Vision. Answering your toughest production Java performance questions

Ahead of Time (AOT) Compilation

Lecture 20. Java Exceptional Event Handling. Dr. Martin O Connor CA166

JamaicaVM Java for Embedded Realtime Systems

Pointers II. Class 31

the gamedesigninitiative at cornell university Lecture 9 Memory Management

MODULE 1 JAVA PLATFORMS. Identifying Java Technology Product Groups

Introduction to Java

Kris Mok, Software Engineer, 莫枢 / 撒迦

Sat 1/6/2018 JAVA (JVM) MEMORY MODEL MEMORY MANAGEMENT IN JAVA... 3 WHERE STORAGE LIVES... 3

Installing on WebLogic Server

Scaling Up Performance Benchmarking

Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St.

The Z Garbage Collector An Introduction

Fundamentals of GC Tuning. Charlie Hunt JVM & Performance Junkie

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime

Research on the Novel and Efficient Mechanism of Exception Handling Techniques for Java. Xiaoqing Lv 1 1 huihua College Of Hebei Normal University,

Designing experiments Performing experiments in Java Intel s Manycore Testing Lab

JVM Performance Study Comparing Oracle HotSpot and Azul Zing Using Apache Cassandra

IBM SDK, Java Technology Edition Version 1. IBM VM messages IBM

Rational Software White Paper

WebOTX Batch Server. November, NEC Corporation, Cloud Platform Division, WebOTX Group

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Kodewerk. Java Performance Services. The War on Latency. Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd.

Enterprise Architect. User Guide Series. Profiling

Enterprise Architect. User Guide Series. Profiling. Author: Sparx Systems. Date: 10/05/2018. Version: 1.0 CREATED WITH

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft.NET Framework Agent Fix Pack 13.

The Z Garbage Collector Low Latency GC for OpenJDK

Advanced Programming & C++ Language

A Study Paper on Performance Degradation due to Excessive Garbage Collection in Java Based Applications using Profiler

Performance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs

Exceptions. CSE 142, Summer 2002 Computer Programming 1.

Exceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.

J2EE Performance Tuning. Jayesh Patel Northern Virginia Java/BEA User Group January 11 th, 2005.

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

Transcription:

Lesson 2 Dissecting Memory Problems Poonam Parhar JVM Sustaining Engineer Oracle

Agenda 1. Symptoms of Memory Problems 2. Causes of Memory Problems 3. OutOfMemoryError messages 3

Lesson 2-1 Symptoms of Memory Problems Poonam Parhar JVM Sustaining Engineer Oracle

Symptoms of Memory Problems Poor Performance of the Application Abnormal Memory Usage Growth OutOfMemoryError Messages 5

Poor Performance of the Application Application not performing to the expected level Long response times Client requests getting dropped Stuck threads Service unavailability 6

Abnormal Memory Usage Growth Continuous memory growth Memory usage spikes 7

8

OutOfMemoryError Messages Encountering OutOfMemoryError for various memory spaces Exception in thread "main" java.lang.outofmemoryerror: Java heap space at java.util.arrays.copyofrange(unknown Source) at java.lang.string.<init>(unknown Source) at java.io.bufferedreader.readline(unknown Source) at java.io.bufferedreader.readline(unknown Source) at com.abc.abcparser.dump(abcparser.java:23) at com.abc.abcparser.mainabcparser.java:59) 9

Lesson 2-2 Causes of Memory Problems Poonam Parhar JVM Sustaining Engineer Oracle

Causes of Memory Problems Misconfiguration of Memory Spaces Memory Leaks Excessive use of Finalizers Explicit GC Invocations 11

Misconfiguration of Memory Spaces Memory spaces configured smaller than the live-set For example Old generation sized smaller than the live-set of Java Objects CodeCache sized smaller than the generated compiled code footprint Young generation not size appropriately causing premature promotion of objects PermGen/Metaspace not sized appropriately causing Full GCs 12

Misconfiguration of Memory Spaces 20.343: [Full GC (Ergonomics) [PSYoungGen: 12799K->12799K(14848K)] [ParOldGen: 33905K->33905K(34304K)] 46705K- >46705K(49152K), [Metaspace: 2921K- >2921K(1056768K)], 0.4595734 secs] [Times: user=1.17 sys=0.00, real=0.46 secs]...<snip>... several Full GCs...</snip>... 22.640: [Full GC (Ergonomics) [PSYoungGen: 12799K->12799K(14848K)] [ParOldGen: 33911K->33911K(34304K)] 46711K- >46711K(49152K), [Metaspace: 2921K- >2921K(1056768K)], 0.4648764 secs] [Times: user=1.11 sys=0.00, real=0.46 secs] 23.108: [Full GC (Ergonomics) [PSYoungGen: 12799K->12799K(14848K)] [ParOldGen: 33913K->33913K(34304K)] 46713K- >46713K(49152K), [Metaspace: 2921K- >2921 K(1056768K)], 0.4380009 secs] [Times: user=1.05 sys=0.00, real=0.44 secs] 23.550: [Full GC (Ergonomics) [PSYoungGen: 12799K->12799K(14848K)] [ParOldGen: 33914K->33914K(34304K)] 46714K- >46714K(49152K), [Metaspace: 2921K- >2921 K(1056768K)], 0.4767477 secs] [Times: user=1.15 sys=0.00, real=0.48 secs] Exception in thread "main" java.lang.outofmemoryerror: GC overhead limit exceeded at oom.main(oom.java:15) 13

Memory Leaks Unintentional retention of objects in the memory spaces Unintentionally holding reference to set of objects in the Java Heap Not de-referencing classloader instances appropriately Not releasing native resources appropriately 14

Excessive use of Finalizers Objects with a finalizer may delay their garbage collection Finalizer thread needs to invoke the finalize() method of the instances before those instances can be reclaimed If the finalizer thread does not keep up with the rate at which the objects become eligible for finalization, the JVM might fail with an OutOfMemoryError Objects piled up in the Finalizer thread s queue would have been otherwise collected Pending finalization objects are essentially accumulated garbage Deprecated in Java 9 15

Explicit GC Invocations System.gc() Diagnostic data collections 16

Lesson 2-3 OutOfMemoryError Poonam Parhar JVM Sustaining Engineer Oracle

What is OutOfMemoryError? When the JVM runs out of space in various memory spaces Thrown when JVM can not proceed further with the process execution Unchecked exception subclassed from java.lang.virtualmachineerror java.lang.throwable java.lang.error java.lang.virtualmachineerror java.lang.outofmemoryerror 18

Understand OutOfMemoryError Exception java.lang.outofmemoryerror: Java heap space java.lang.outofmemoryerror: GC Overhead limit exceeded java.lang.outofmemoryerror: Requested array size exceeds VM limit java.lang.outofmemoryerror: PermGen Space java.lang.outofmemoryerror: Metaspace java.lang.outofmemoryerror: Compressed class space Native Memory java.lang.outofmemoryerror: request size bytes for <reason>. Out of swap space? java.lang.outofmemoryerror: <reason> stack_trace_with_native_method 19

What is in Java Heap? Java objects get allocated in the Java Heap String s = new String( Hello Java ); The allocated String object resides in the Java Heap first in the young generation and if it lives long enough, then in the old generation 20

java.lang.outofmemoryerror: Java heap space This error means that the Java Heap is filled with Java Objects and the application is requesting to allocate more Java Objects The JVM has already invoked Full GC but could not free up any space It could be that the Java Heap is sized smaller than the application footprint or the application is unintentionally holding on to some set of objects in the heap 21

java.lang.outofmemoryerror: GC Overhead limit exceeded This message means Too many GCs Freeing up very little to no space Application threads not getting any CPU cycles Could be thrown due to the Java Heap Space or PermGen/Metaspace being almost Full Need to look into which space is running out of memory 22

java.lang.outofmemoryerror: Requested array size exceeds VM limit Attempt to allocate an array larger than Java heap size maximum permitted array size: Integer.MAX_VALUE-2 23

What is in PermGen? Classes and classes metadata get stored in the PermGen Static as well as dynamically loaded classes Note: PermGen removed in JDK 8 24

java.lang.outofmemoryerror: PermGen Space This means that the PermGen is full with the loaded classes and their metadata and the application is requesting to load more classes The JVM has already invoked Full GC including the cleaning of PermGen but could not free up any space in the PermGen It could be that the PermGen is sized smaller than the footprint of classes and their metadata, or the application is unintentionally holding on to some set of classes in the PermGen When the PermGen is full, Full GC is invoked to collect it 25

What is in Metaspace? Classes and classes metadata get stored in the Metaspace Static as well as dynamically loaded classes Metaspace is not part of the Java heap and is allocated out of native memory 26

java.lang.outofmemoryerror: Metaspace Metaspace by default is unlimited MaxMetaspaceSize This exception means that the Metaspace is full with the loaded classes and their metadata, and the application is requesting to load more classes The JVM has already invoked Full GC but could not free up any space in the Metaspace Indicates: the Metaspace is sized smaller than the footprint of classes and its metadata, or the application is unintentionally holding on to some set of classes in the Metaspace 27

java.lang.outofmemoryerror: Compressed class space If UseCompressedClassPointers is enabled, then two separate areas of native memory are used for the classes and their metadata UseCompressedClassPointers is enabled by default if UseCompressedOops is turned on UseCompressedClassPointers, 64-bit class pointers are represented with 32-bit values, and these compressed class pointers are stored in the compressed class space By default, this compressed class space is sized at 1GB and can be configured using CompressedClassSpaceSize MaxMetaspaceSize sets an upper limit on the total committed size of both of these regions 28

What is in Native Memory? Java Thread Stacks Loaded jar and zip files Loaded native libraries Native resources e.g. files Memory allocated from the native code e.g. JNI 29

OutOfMemoryError for Native Memory # A fatal error has been detected by the Java Runtime Environment: # # java.lang.outofmemoryerror: requested 32756 bytes for ChunkPool::allocate. Out of swap space? # # Internal Error (allocation.cpp:166), pid=2290, tid=27 # Error: ChunkPool::allocate # A fatal error has been detected by the Java Runtime Environment: # # java.lang.outofmemoryerror : unable to create new native Thread 30

OutOfMemoryError for Native Memory JVM is not able to allocate from native memory One or more processes are consuming all of native memory Could mean a native memory leak 31

Summary Misconfiguration of Memory Pools Memory Leaks Excessive use of Finalizers Explicit GC Invocations Long GC Pauses Excessive GCs Can lead to Can manifest as Poor Application Performance Unexpected Memory Growth Application Failure with OutOfMemoryError 32