SlideShare a Scribd company logo
1 of 28
Download to read offline
OutOfMemory



     Analyse von Laufzeitproblemen bei
     Java / J2EE Appliakationen

     Communardo Software GmbH
     Marko Seifert
     Dresden, 22.05.2008
Motivation und Gliederung

•    analysiere OutOfMemory Probleme seit ca. 2 Jahren in
     verschiedenen Projekten
      • Einsatz verschiedener Tools
      • Strukturiertes Vorgehen beim Analysieren


•    Gliederung:
      • Grundlagen
      • Betriebskennzahlen ermitteln
      • Analyse von Speicherdumps (MemoryLeaks?)




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 2
Grundlagen
Speicher für den Java-Prozess
•    Die Process Size
      • maximale Speicher für
         einen Prozess

          • ist abhängig vom Betriebssystem
            und von der Hardware
            (4 GB bei 32 Bit, HugeMem-
            Kernel, Linux)

          • wird benötigt für:
                                      • Heap
                                      • Native Code
                                      • Permanent Generation


© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 4
Speicher für den Java-Prozess
Der Heap
•    Speicher für die Erzeugung
     der Objekte
     Object a = new Object ();
•    Größe ist begrenzt; wird nichts
     angegeben gelten Systemdefaults
•    2 Bereiche:
       • New Generation
                                      • Anlegen von
                                        neuen Objekten
          • Old Generation
                                      • Verwaltung der älteren, noch benötigten Objekte


© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 5
Speicher für den Java-Prozess



•    New Generation ist unterteilt in:

          • Eden:
                                      • Anlegen der
                                        Objekte
          • 2 Survivior Bereiche (From/To)
                                      • Zwischenspeicher für das Ermitteln von noch
                                        lebenden Objekte (Referenzen von lebenden
                                        Threads auf die Objekte)

© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 6
Heap-Parameter
•    Heapsize explizit angegeben
     JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -Xms1024m -Xmx1024mquot;


•    Servereinstellung (Heapverteilung old:new 1:3)
     JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -serverquot;


•    Heapdump bei OOM
     JAVA_VM_ARGS=quot;-XX:+HeapDumpOnOutOfMemoryErrorquot;


•    Parallele GC
     JAVA_VM_ARGS=quot;$JAVA_VM_ARGS
        -XX:+UseParallelGC
        -XX:UseParallelOldGCquot;

© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 7
Betriebskennzahlen
ermitteln
Speicher für Prozess
•    Aktuelle Speicher für einen Prozess
     top -p <PID> (Linux)
•    Betriebssystem bestimmen (Kernelversion)
     uname -r (Linux)
•    In Betriebssystemspezifikation nachlesen (z.B. bei RedHat)
     http://www.redhat.com/docs/manuals/enterprise/RHEL-4-
     Manual/release-notes/as-x86/

     Red Hat Enterprise Linux 4 includes a kernel known as the hugemem
     kernel. This kernel supports a 4GB per-process user space (versus
     3GB for the other kernels), and a 4GB direct kernel space.



© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 9
Speicher für Prozess
•    OutOfMemory in Native Code
      • Process Size zu klein
        Process Size – Heap – PermSize = Speicher für Native Code
      • MemoryLeak in Native Code
                                      • File.deleteOnExit(); //JDK

           • Kernel beendet Java-Prozess
             An unexpected exception has been detected in
             native code outside the VM.




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 10
GC-Verlauf überwachen
•    GC-Logging aktivieren
     JAVA_VM_ARGS=quot;$JAVA_VM_ARGS
         -verbose:gc -Xloggc:var/logs/gc.log
         -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC
         -XX:+PrintTenuringDistributionquot;
•    gc.log mit HPjtune
     auswerten


•    Kurz vor OutOfMemory
     kann durch GC kaum
     noch Speicher freigegeben
     werden




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 11
Monitoring mit JMeter
Einrichten eines Users für die Management-Seiten


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
     ...
     <role rolename=quot;adminquot;/>
     <role rolename=quot;managerquot;/>
     <user username=quot;adminquot;
        password=quot;adminquot;
        roles=quot;admin, managerquot;/>
     ...
</tomcat-users>


© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 12
Monitoring mit JMeter
Tomcat Monitoring URL
http://HOST:PORT/manager/status?XML=true


<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<status>
     <jvm>
           <memory free='206.306.536'
              total='424.214.528'
              max='492.175.360'/>
     </jvm>
     ...
</status>


© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 13
Monitoring mit JMeter




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 14
Monitoring mit JMeter




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 15
JMX und JConsole
•   JMX Konfiguration
    JAVA_VM_ARGS=quot;$JAVA_VM_ARGS
        -Dcom.sun.management.jmxremote
        -Dcom.sun.management.jmxremote.port=8086
        -Dcom.sun.management.jmxremote.ssl=false
        -Dcom.sun.management.jmxremote.authenticate=
           falsequot;


•   jconsole [processID]




      © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

      Folie 16
JMX und JConsole




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 17
Profilerseite (CAE) + shell script
•    Auswertung von Apache Logfiles per shell script
•    Profilerseite der CAE mit shell script ausgelesen und in CSV-Datei
     geschrieben
•    Auswertung und Visualisierung mit Excel
Internet 1.2
Datum:                                10.05.2007      11.05.2007     12.05.2007      13.05.2007   14.05.2007   15.05.2007   16.05.2007
alle Aufrufe:                             560966          702092         514152          443465      334097       561757       568876
Google:                                     56038          39199            4669          69170        3578         5221         6276
statisches PDF:                              2840           5991            2682           2341        1203         3057         2272
PDFReactor:                                  2530           2611             197           4163         142          195          243
neue Session
(exkl. URL Rewriting):                      52150          43027           18085          57074       14474        20191        21947
Google Session:                             37823          30581             967          55440        1490          814         1385
ask Session:                                 7041           6178             625          11396         484          642          865




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 18
© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 19
Analyse von Speicherdumps
Speicherdump erstellen

•    Histogramm
     /.../jdk1.5.0/bin/jmap -histo <PID> > hist.txt
•    Binary HeapDump (komplett)
     /.../jdk1.5.0/bin/jmap -heap:format=b <PID>




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 21
JHat (JDK 1.6)

java -Xmx2048m -jar hat.jar ../java_pid27280.hprof
  Started HTTP server on port 7000
  Reading from ../java_pid27280.hprof...
  Dump file created Tue Nov 20 14:22:07 CET 2007




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 22
SAP Memory Analyzer
•    kostenloses Tool zum Analysieren von großen Memory Dumps
      • sehr schnelle (durch Indizierung)
      • sehr gute Analysemöglichkeiten
      • Bearbeitung großer Dumps
      • als Eclipse Plugin oder eigenständige Applikation (RPC-
         Framework)
•    Artikel im JavaMagazin (11/2007 S.105)


•    Download:
     https://www.sdn.sap.com/irj/sdn/java?rid=/library/uuid/a0f47c83-5ef6-
     2910-2c89-b75d296edef9


© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 23
© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 24
© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 25
© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 26
© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 27
OutOfMemory

•    MemoryLeak durch CGLIB (Hibernate, EHCache, CoreMedia
     Dataviews, …)
•    ThreadLocal Variablen und ThreadPool des Tomcats
     http://opensource.atlassian.com/confluence/spring/pages/viewpage.a
     ction?pageId=2669




© Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de

Folie 28

More Related Content

Similar to Systemanalyse von OutOfMemory Fehlern in Java-Anwendungen

System Center Configuration Manager with Azure, Intune and Application Manage...
System Center Configuration Manager with Azure, Intune and Application Manage...System Center Configuration Manager with Azure, Intune and Application Manage...
System Center Configuration Manager with Azure, Intune and Application Manage...Digicomp Academy AG
 
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHDocker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHagilemethoden
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT CoreJens Siebert
 
Klappe auf! Was macht die JVM denn da? [Ger]
Klappe auf! Was macht die JVM denn da? [Ger]Klappe auf! Was macht die JVM denn da? [Ger]
Klappe auf! Was macht die JVM denn da? [Ger]Tobias Frech
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT CoreJens Siebert
 
Django & Buildout
Django & BuildoutDjango & Buildout
Django & Buildoutzerok
 
20121008 io-performance
20121008 io-performance20121008 io-performance
20121008 io-performanceWerner Fischer
 
Monitoring von SAP mit check_sap_health
Monitoring von SAP mit check_sap_healthMonitoring von SAP mit check_sap_health
Monitoring von SAP mit check_sap_healthGerhard Lausser
 
Augmented Reality Workshop
Augmented Reality WorkshopAugmented Reality Workshop
Augmented Reality Workshopargency
 
Oracle connection manager_cman_doag_sig_security_mai_2015
Oracle connection manager_cman_doag_sig_security_mai_2015Oracle connection manager_cman_doag_sig_security_mai_2015
Oracle connection manager_cman_doag_sig_security_mai_2015Gunther Pippèrr
 
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...NETWAYS
 
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...Klaus Bild
 
Maemo 5 Developer Workshop @ Metalab
Maemo 5 Developer Workshop @ MetalabMaemo 5 Developer Workshop @ Metalab
Maemo 5 Developer Workshop @ Metalabthp4
 
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias Gallinger
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias GallingerOSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias Gallinger
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias GallingerNETWAYS
 
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technisch
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technischBarrierefreie Internet und Intranetseiten mit Sharepoint Server - technisch
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technischSharepointUGDD
 
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...OPITZ CONSULTING Deutschland
 
C1 Adcon Backup For Domino
C1 Adcon Backup For DominoC1 Adcon Backup For Domino
C1 Adcon Backup For DominoAndreas Schulte
 
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)data://disrupted®
 

Similar to Systemanalyse von OutOfMemory Fehlern in Java-Anwendungen (20)

System Center Configuration Manager with Azure, Intune and Application Manage...
System Center Configuration Manager with Azure, Intune and Application Manage...System Center Configuration Manager with Azure, Intune and Application Manage...
System Center Configuration Manager with Azure, Intune and Application Manage...
 
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHDocker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT Core
 
Klappe auf! Was macht die JVM denn da? [Ger]
Klappe auf! Was macht die JVM denn da? [Ger]Klappe auf! Was macht die JVM denn da? [Ger]
Klappe auf! Was macht die JVM denn da? [Ger]
 
Windows 10 IoT Core
Windows 10 IoT CoreWindows 10 IoT Core
Windows 10 IoT Core
 
Django & Buildout
Django & BuildoutDjango & Buildout
Django & Buildout
 
20121008 io-performance
20121008 io-performance20121008 io-performance
20121008 io-performance
 
Monitoring von SAP mit check_sap_health
Monitoring von SAP mit check_sap_healthMonitoring von SAP mit check_sap_health
Monitoring von SAP mit check_sap_health
 
Augmented Reality Workshop
Augmented Reality WorkshopAugmented Reality Workshop
Augmented Reality Workshop
 
Oracle connection manager_cman_doag_sig_security_mai_2015
Oracle connection manager_cman_doag_sig_security_mai_2015Oracle connection manager_cman_doag_sig_security_mai_2015
Oracle connection manager_cman_doag_sig_security_mai_2015
 
GPUs — Vom spezialisierten Coprozessor zum Numbercruncher
GPUs — Vom spezialisierten Coprozessor zum NumbercruncherGPUs — Vom spezialisierten Coprozessor zum Numbercruncher
GPUs — Vom spezialisierten Coprozessor zum Numbercruncher
 
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...
Nagios Conference 2006 | Automatisierung von Performancecharts mit dem Nagios...
 
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
The Best Things in Life Are Free – Wie Sie Ihre IBM ConnecEons Umgebung koste...
 
Maemo 5 Developer Workshop @ Metalab
Maemo 5 Developer Workshop @ MetalabMaemo 5 Developer Workshop @ Metalab
Maemo 5 Developer Workshop @ Metalab
 
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias Gallinger
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias GallingerOSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias Gallinger
OSMC 2018 | Netzwerkmonitoring mit Prometheus by Matthias Gallinger
 
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technisch
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technischBarrierefreie Internet und Intranetseiten mit Sharepoint Server - technisch
Barrierefreie Internet und Intranetseiten mit Sharepoint Server - technisch
 
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...
Wie baue ich eine KI, die besser als jeder Mensch ein Problem und dessen Ursa...
 
C1 Adcon Backup For Domino
C1 Adcon Backup For DominoC1 Adcon Backup For Domino
C1 Adcon Backup For Domino
 
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)
Hochleistungsspeichersysteme für Datenanalyse an der TU Dresden (Michael Kluge)
 
Infrastructure Solution Day | Core
Infrastructure Solution Day | CoreInfrastructure Solution Day | Core
Infrastructure Solution Day | Core
 

More from Communardo GmbH

Solution Guide I / 2020_1
Solution Guide I / 2020_1Solution Guide I / 2020_1
Solution Guide I / 2020_1Communardo GmbH
 
Solution Guide II / 2018
Solution Guide II / 2018Solution Guide II / 2018
Solution Guide II / 2018Communardo GmbH
 
Solution Guide II / 2018
Solution Guide II / 2018Solution Guide II / 2018
Solution Guide II / 2018Communardo GmbH
 
Tino Schmidt | Communardo | Per Anhalter durch den Digital Workplace
Tino Schmidt | Communardo | Per Anhalter durch den Digital WorkplaceTino Schmidt | Communardo | Per Anhalter durch den Digital Workplace
Tino Schmidt | Communardo | Per Anhalter durch den Digital WorkplaceCommunardo GmbH
 
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?Communardo GmbH
 
Social Business Solution Guide I/2017
Social Business Solution Guide I/2017Social Business Solution Guide I/2017
Social Business Solution Guide I/2017Communardo GmbH
 
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...Communardo GmbH
 
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbH
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbHArchitektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbH
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbHCommunardo GmbH
 
Social Business Solution Guide III/2016
Social Business Solution Guide III/2016Social Business Solution Guide III/2016
Social Business Solution Guide III/2016Communardo GmbH
 
CatWorkX Midsummer Day 2016 - Workshop Session
CatWorkX Midsummer Day 2016 - Workshop SessionCatWorkX Midsummer Day 2016 - Workshop Session
CatWorkX Midsummer Day 2016 - Workshop SessionCommunardo GmbH
 
Communote ist Open Source
Communote ist Open SourceCommunote ist Open Source
Communote ist Open SourceCommunardo GmbH
 
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRA
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRAAUG Bodensee: Die Top10 Add-ons für Confluence & JIRA
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRACommunardo GmbH
 
Communardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo GmbH
 
Communardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo GmbH
 

More from Communardo GmbH (20)

Solution Guide I / 2020_1
Solution Guide I / 2020_1Solution Guide I / 2020_1
Solution Guide I / 2020_1
 
Solution Guide I / 2020
Solution Guide I / 2020Solution Guide I / 2020
Solution Guide I / 2020
 
Solution guide 2019
Solution guide 2019Solution guide 2019
Solution guide 2019
 
Solution Guide II / 2018
Solution Guide II / 2018Solution Guide II / 2018
Solution Guide II / 2018
 
Solution Guide II/2018
Solution Guide II/2018Solution Guide II/2018
Solution Guide II/2018
 
Solution Guide II / 2018
Solution Guide II / 2018Solution Guide II / 2018
Solution Guide II / 2018
 
Solution Guide I / 2018
Solution Guide I / 2018Solution Guide I / 2018
Solution Guide I / 2018
 
Tino Schmidt | Communardo | Per Anhalter durch den Digital Workplace
Tino Schmidt | Communardo | Per Anhalter durch den Digital WorkplaceTino Schmidt | Communardo | Per Anhalter durch den Digital Workplace
Tino Schmidt | Communardo | Per Anhalter durch den Digital Workplace
 
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?
Michael Stelzner | Communardo | Ist "Agil" das neue "Normal"?
 
The new digital divide
The new digital divideThe new digital divide
The new digital divide
 
Solution Guide ll 2017
Solution Guide ll 2017Solution Guide ll 2017
Solution Guide ll 2017
 
Social Business Solution Guide I/2017
Social Business Solution Guide I/2017Social Business Solution Guide I/2017
Social Business Solution Guide I/2017
 
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...
Das technologische Fundament des Digital Workplace / Alexander Buder, Communa...
 
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbH
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbHArchitektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbH
Architektur von Anwendungsintegrationen / Tino Winkler, Communardo Software GmbH
 
Social Business Solution Guide III/2016
Social Business Solution Guide III/2016Social Business Solution Guide III/2016
Social Business Solution Guide III/2016
 
CatWorkX Midsummer Day 2016 - Workshop Session
CatWorkX Midsummer Day 2016 - Workshop SessionCatWorkX Midsummer Day 2016 - Workshop Session
CatWorkX Midsummer Day 2016 - Workshop Session
 
Communote ist Open Source
Communote ist Open SourceCommunote ist Open Source
Communote ist Open Source
 
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRA
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRAAUG Bodensee: Die Top10 Add-ons für Confluence & JIRA
AUG Bodensee: Die Top10 Add-ons für Confluence & JIRA
 
Communardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo Social Business Solution Guide
Communardo Social Business Solution Guide
 
Communardo Social Business Solution Guide
Communardo Social Business Solution GuideCommunardo Social Business Solution Guide
Communardo Social Business Solution Guide
 

Systemanalyse von OutOfMemory Fehlern in Java-Anwendungen

  • 1. OutOfMemory Analyse von Laufzeitproblemen bei Java / J2EE Appliakationen Communardo Software GmbH Marko Seifert Dresden, 22.05.2008
  • 2. Motivation und Gliederung • analysiere OutOfMemory Probleme seit ca. 2 Jahren in verschiedenen Projekten • Einsatz verschiedener Tools • Strukturiertes Vorgehen beim Analysieren • Gliederung: • Grundlagen • Betriebskennzahlen ermitteln • Analyse von Speicherdumps (MemoryLeaks?) © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 2
  • 4. Speicher für den Java-Prozess • Die Process Size • maximale Speicher für einen Prozess • ist abhängig vom Betriebssystem und von der Hardware (4 GB bei 32 Bit, HugeMem- Kernel, Linux) • wird benötigt für: • Heap • Native Code • Permanent Generation © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 4
  • 5. Speicher für den Java-Prozess Der Heap • Speicher für die Erzeugung der Objekte Object a = new Object (); • Größe ist begrenzt; wird nichts angegeben gelten Systemdefaults • 2 Bereiche: • New Generation • Anlegen von neuen Objekten • Old Generation • Verwaltung der älteren, noch benötigten Objekte © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 5
  • 6. Speicher für den Java-Prozess • New Generation ist unterteilt in: • Eden: • Anlegen der Objekte • 2 Survivior Bereiche (From/To) • Zwischenspeicher für das Ermitteln von noch lebenden Objekte (Referenzen von lebenden Threads auf die Objekte) © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 6
  • 7. Heap-Parameter • Heapsize explizit angegeben JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -Xms1024m -Xmx1024mquot; • Servereinstellung (Heapverteilung old:new 1:3) JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -serverquot; • Heapdump bei OOM JAVA_VM_ARGS=quot;-XX:+HeapDumpOnOutOfMemoryErrorquot; • Parallele GC JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -XX:+UseParallelGC -XX:UseParallelOldGCquot; © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 7
  • 9. Speicher für Prozess • Aktuelle Speicher für einen Prozess top -p <PID> (Linux) • Betriebssystem bestimmen (Kernelversion) uname -r (Linux) • In Betriebssystemspezifikation nachlesen (z.B. bei RedHat) http://www.redhat.com/docs/manuals/enterprise/RHEL-4- Manual/release-notes/as-x86/ Red Hat Enterprise Linux 4 includes a kernel known as the hugemem kernel. This kernel supports a 4GB per-process user space (versus 3GB for the other kernels), and a 4GB direct kernel space. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 9
  • 10. Speicher für Prozess • OutOfMemory in Native Code • Process Size zu klein Process Size – Heap – PermSize = Speicher für Native Code • MemoryLeak in Native Code • File.deleteOnExit(); //JDK • Kernel beendet Java-Prozess An unexpected exception has been detected in native code outside the VM. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 10
  • 11. GC-Verlauf überwachen • GC-Logging aktivieren JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -verbose:gc -Xloggc:var/logs/gc.log -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistributionquot; • gc.log mit HPjtune auswerten • Kurz vor OutOfMemory kann durch GC kaum noch Speicher freigegeben werden © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 11
  • 12. Monitoring mit JMeter Einrichten eines Users für die Management-Seiten <?xml version='1.0' encoding='utf-8'?> <tomcat-users> ... <role rolename=quot;adminquot;/> <role rolename=quot;managerquot;/> <user username=quot;adminquot; password=quot;adminquot; roles=quot;admin, managerquot;/> ... </tomcat-users> © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 12
  • 13. Monitoring mit JMeter Tomcat Monitoring URL http://HOST:PORT/manager/status?XML=true <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <status> <jvm> <memory free='206.306.536' total='424.214.528' max='492.175.360'/> </jvm> ... </status> © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 13
  • 14. Monitoring mit JMeter © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 14
  • 15. Monitoring mit JMeter © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 15
  • 16. JMX und JConsole • JMX Konfiguration JAVA_VM_ARGS=quot;$JAVA_VM_ARGS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate= falsequot; • jconsole [processID] © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 16
  • 17. JMX und JConsole © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 17
  • 18. Profilerseite (CAE) + shell script • Auswertung von Apache Logfiles per shell script • Profilerseite der CAE mit shell script ausgelesen und in CSV-Datei geschrieben • Auswertung und Visualisierung mit Excel Internet 1.2 Datum: 10.05.2007 11.05.2007 12.05.2007 13.05.2007 14.05.2007 15.05.2007 16.05.2007 alle Aufrufe: 560966 702092 514152 443465 334097 561757 568876 Google: 56038 39199 4669 69170 3578 5221 6276 statisches PDF: 2840 5991 2682 2341 1203 3057 2272 PDFReactor: 2530 2611 197 4163 142 195 243 neue Session (exkl. URL Rewriting): 52150 43027 18085 57074 14474 20191 21947 Google Session: 37823 30581 967 55440 1490 814 1385 ask Session: 7041 6178 625 11396 484 642 865 © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 18
  • 19. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 19
  • 21. Speicherdump erstellen • Histogramm /.../jdk1.5.0/bin/jmap -histo <PID> > hist.txt • Binary HeapDump (komplett) /.../jdk1.5.0/bin/jmap -heap:format=b <PID> © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 21
  • 22. JHat (JDK 1.6) java -Xmx2048m -jar hat.jar ../java_pid27280.hprof Started HTTP server on port 7000 Reading from ../java_pid27280.hprof... Dump file created Tue Nov 20 14:22:07 CET 2007 © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 22
  • 23. SAP Memory Analyzer • kostenloses Tool zum Analysieren von großen Memory Dumps • sehr schnelle (durch Indizierung) • sehr gute Analysemöglichkeiten • Bearbeitung großer Dumps • als Eclipse Plugin oder eigenständige Applikation (RPC- Framework) • Artikel im JavaMagazin (11/2007 S.105) • Download: https://www.sdn.sap.com/irj/sdn/java?rid=/library/uuid/a0f47c83-5ef6- 2910-2c89-b75d296edef9 © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 23
  • 24. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 24
  • 25. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 25
  • 26. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 26
  • 27. © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 27
  • 28. OutOfMemory • MemoryLeak durch CGLIB (Hibernate, EHCache, CoreMedia Dataviews, …) • ThreadLocal Variablen und ThreadPool des Tomcats http://opensource.atlassian.com/confluence/spring/pages/viewpage.a ction?pageId=2669 © Communardo Software GmbH · Fon +49 (0) 351 833820 · info@communardo.de · www.communardo.de Folie 28