Javaforum looking into the memory

27
Out Of Memory Analyze Your Java Heap

description

Out Of Memory - Analyze Your Java HeapA short introduction on why memory usage might not be what you expect it to be and tools for going deeper. Different ways for acquiring memory snapshots and how to examine them with MAT. Roger Lindsjö, Ericsson

Transcript of Javaforum looking into the memory

Page 1: Javaforum   looking into the memory

Out Of MemoryOut Of MemoryAnalyze Your Java HeapAnalyze Your Java Heap

Page 2: Javaforum   looking into the memory

GC silver bullet

Unreferenced memory cleared

Fragmentation cleanup

Incorrect understanding of data / structures

Packratting

Page 3: Javaforum   looking into the memory

Data / Structures

Primitives vs Objects

Byte vs byte

Overhead of structure

LinkedList vs ArrayList

JVM settings

UseCompressedOops, UseCompressedStrings

Page 4: Javaforum   looking into the memory

Packratting

Unintentionally storing data

Unbounded caches

Classloaders

Containers / plugins

ThreadLocals

Statics

Page 5: Javaforum   looking into the memory

What now

Avoid situation ;-)

Page 6: Javaforum   looking into the memory

Snapshot

-XX:+HeapDumpOnCtrlBreak

-XX:+HeapDumpOnOutOfMemoryError

jmap -dump:format=b,file=snapshot.bin pid

jconsole

Page 7: Javaforum   looking into the memory
Page 8: Javaforum   looking into the memory

MATEclipse Memory Analyzer

Wizards

Compare

Explore

Query

Page 9: Javaforum   looking into the memory
Page 10: Javaforum   looking into the memory
Page 11: Javaforum   looking into the memory
Page 12: Javaforum   looking into the memory
Page 13: Javaforum   looking into the memory
Page 14: Javaforum   looking into the memory
Page 15: Javaforum   looking into the memory
Page 16: Javaforum   looking into the memory
Page 17: Javaforum   looking into the memory
Page 18: Javaforum   looking into the memory
Page 19: Javaforum   looking into the memory
Page 20: Javaforum   looking into the memory
Page 21: Javaforum   looking into the memory
Page 22: Javaforum   looking into the memory
Page 23: Javaforum   looking into the memory
Page 24: Javaforum   looking into the memory
Page 25: Javaforum   looking into the memory
Page 26: Javaforum   looking into the memory

Can be large

Takes time to produce

Can contain sensitive information

Watch out

Page 27: Javaforum   looking into the memory

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/