zoukankan      html  css  js  c++  java
  • java core dump和heap dump文件

    http://www.cnblogs.com/xzpp/archive/2011/10/10/2206619.html

    1. core dump和heap dump文件

    core dump
    保存cpu,jvm相关的信息,主要保存的是java应用各线程在某一时刻的运行的位置,即执行到哪一个类的哪一个方法哪一个行上。javacore是一个文本文件,打开后可以看到每一个线程的执行栈,以stacktrace的方式显示。通过对javacore的分析可以得到应用是否“卡”在某一点上,即在某一点运行的时间太长,如数据库查询,长期得不到响应,最终导致系统崩溃。

    heap dump
    保存java程序内存使用情况。heapdump文件是一个二进制文件,它保存了某一时刻jvm堆中对象情况,这种文件需要相应的工具进行分析,用得较多的是heap analyzer这个工具。这个文件最重要的作用就是分析系统是否存在内存溢出的情况,通过heapanalyzer可以很简单地分析出溢出的位置。

    在linux/unix上执行kill -3 <pid>命令可以生成javacore文件和heapdump文件

    2. core dump 和heap dump分析工具
    core dump分析工具: IBM Thread and Monitor Dump Analyze
    heap dump分析工具:  MDD4J or Heap Analyzer.

    其他工具: VisualVM, Netbeans or Eclipse's Memory Analyzer Tool

    //TODO 加个分析实例




    3. 关于core dump 和heap dump的一篇转载  
    来自  Introduction to Heap Dump & Core Dump

    Core dump and heap dumps:

    java core is a snapshot of the threads at work in a JVM. It also details a cross section of information from the major components in the JVM like XM,XE, LK, etc (IBM Javacore only, Sun does not – it just shows threads)

    A Java dump, also known as a Java core, Java thread dump, or a thread dump is a file that contains the following sections:

    • All of the threads that run on a Java Virtual Machine (JVM).
    • All of the monitors on a JVM.
    • Some useful information about the system that the JVM runs under.

    heapdump is a snapshot of JVM memory – it shows the live objects on the heap along with references between objects. It is used to determine memory usage patterns and memory leak suspects.

    Generating dumps:

    Both can be created by issuing a kill -3 on the PID of the JVM process. There are other ways to gather these docs as well (wsadmin scripts)

    If the kill command does not produce the dumps, you can always generate one with a JACL/Jython script via the wsadmin interface

    JACL

    set jvm $AdminControl completeObjectName type=JVM,*

    $AdminControl invoke $jvm dumpThreads

    set jvm $AdminControl completeObjectName type=JVM,*

    $AdminControl invoke $jvm generateHeapDump

    Jython

    jvm = AdminControl.completeObjectName(‘type=JVM,process=server1,*’)

    AdminControl.invoke(jvm, ‘dumpThreads’)

    The heapdump and a javacore should be created in the WebSphere/AppServer directory. You can confirm this by reviewing the verbose GC output after issuing the kill command.

    ThreadAnalyzer:

    • ThreadAnalyzer is a problem determination tool for WebSphere Application Server thread performance and deadlock detection. You can use it to obtain a Java dump from an application server and use its analysis features for problem determination. For performance problem determination, ThreadAnalyzer provides a top-of-the-stack (TOS) analysis that counts all of the methods at the top of the stack for the listed threads.
    • It then sorts them by ‘weight’ (automatically computed by ThreadAnalyzer), and lists the possible performance bottlenecks in your application. ThreadAnalyzer does automatic deadlock detection while it analyzes the Java dump.

    Downloading ThreadAnalyzer

    To download ThreadAnalyzer go to

    http://www.ibm.com/developerworks/websphere/downloads/thread_analyzer.html

    What is IBM Thread and Monitor Dump Analyzer for Java?

    • During the run time of a Java™ process, some Java Virtual Machiness (JVMs) may not respond predictably and oftentimes seem to hang up for a long time or until JVM shutdown occurs. It is not easy to determine the root cause of these sorts of problems.
    • By triggering a javacore when a Java process does not respond, it is possible to collect diagnostic information related to the JVM and a Java application captured at a particular point during execution. For example, the information can be about the operating system, the application environment, threads, native stack, locks, and memory. The exact contents are dependent on the platform on which the application is running.
    • On some platforms, and in some cases, javacore is known as “javadump.” The code that creates javacore is part of the JVM. One can control it by using environment variables and run-time switches. By default, a javacore occurs when the JVM terminates unexpectedly. A javacore can also be triggered by sending specific signals to the JVM. Although javacore or javadump is present in Sun Solaris JVMs, much of the content of the javacore is added by IBM and, therefore, is present only in IBM JVMs.
    • IBM Thread and Monitor Dump Analyzer for Java analyzes javacore and diagnoses monitor locks and thread activities in order to identify the root cause of hangs, deadlocks, and resource contention or monitor bottlenecks.

    How does it work?

    • This technology analyzes each thread information and provides diagnostic information, such as current thread information, the signal that caused the javacore, Java heap information (maximum Java heap size, initial Java heap size, garbage collector counter, allocation failure counter, free Java heap size, and allocated Java heap size), number of runnable threads, total number of threads, number of monitors locked, and deadlock information.
    • In addition, IBM Thread and Monitor Dump Analyzer for Java provides the recommended size of the Java heap cluster (applicable only to IBM SDK 1.4.2 and 1.3.1 SR7 or above) based on the heuristic analysis engine.
    • IBM Thread and Monitor Dump Analyzer for Java compares each javacore and provides process ID information for threads, time stamp of the first javacore, time stamp of the last javacore, number of garbage collections per minute, number of allocation failures per minute, time between the first javacore and the last javacore, number of hang suspects, and list of hang suspects.
    • This technology also compares all monitor information in javacore and detects deadlock and resource contention or monitor bottlenecks, if there are any.

    What is HeapAnalyzer?

    • HeapAnalyzer allows the finding of a possible Java™ heap leak area through its heuristic search engine and analysis of the Java heap dump in Java applications.
    • Java heap areas define objects, arrays, and classes. When the Garbage Collector allocates areas of storage in the heap, an object continues to be live while a reference to it exists somewhere in the active state of the JVM; therefore the object is reachable. When an object ceases to be referenced from the active state, it becomes garbage and can be reclaimed for reuse.

    • When this reclamation occurs, the Garbage Collector must process a possible finalizer and also ensure that any internal JVM resources that are associated with the object are returned to the pool of such resources. Java heap dumps are snap shots of Java heaps at specific times.

    How does it work?

    HeapAnalyzer analyzes Java heap dumps by parsing the Java heap dump, creating directional graphs, transforming them into directional trees, and executing the heuristic search engine.

    The following are examples of features:

    • List of Java heap leak suspects
    • Recommendation of the size of kCluster
    • List of gaps among allocated objects/classes/arrays
    • Java objects/classes/arrays search engine
    • List of objects/classes/arrays by type name
    • List of objects/classes/arrays by object name
    • List of objects/classes/arrays by address
    • List of objects/classes/arrays by size
    • List of objects/classes/arrays by size of child
    • List of objects/classes/arrays by number of child
    • List of objects/classes/arrays by frequency
    • List of available heap spaces by size
    • Tree view of Java heap dump
    • Loading/saving processed Java heap dumps.
  • 相关阅读:
    LG P4284 [SHOI2014]概率充电器
    LG P2592 [ZJOI2008]生日聚会
    LG P4953 [USACO02FEB]Cow Cycling
    LG P2389 电脑班的裁员
    LG P2344 [USACO11FEB]Generic Cow Protests G
    前端简历
    前端面试题目
    大前端的技术栈
    前端 -为什么要清楚浮动?
    Redis的功能实现
  • 原文地址:https://www.cnblogs.com/balaamwe/p/2295778.html
Copyright © 2011-2022 走看看