Javaforum looking into the memory

Post on 01-Nov-2014

1.456 views 2 download

Tags:

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

Out Of MemoryOut Of MemoryAnalyze Your Java HeapAnalyze 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

MATEclipse Memory Analyzer

Wizards

Compare

Explore

Query

Can be large

Takes time to produce

Can contain sensitive information

Watch out

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/