Differences between Heap Dump, thread dump and core dump (#14718)

* Differences between Heap Dump, thread dump and core dump

* Differences between Heap Dump, thread dump and core dump

* Differences between Heap Dump, thread dump and core dump

* Differences Between Heap Dump, Thread Dump and Core Dump
This commit is contained in:
Michael Olayemi 2023-09-13 01:18:47 +00:00 committed by GitHub
parent 7c02a6ffdb
commit cc911cefeb
5 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#include <jni.h>
#include "CoreDump.h"
void core() {
int *p = NULL;
*p = 0;
}
JNIEXPORT void JNICALL Java_CoreDump_core (JNIEnv *env, jobject obj) {
core();
};
void main() {
}

View File

@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class CoreDump */
#ifndef _Included_CoreDump
#define _Included_CoreDump
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: CoreDump
* Method: core
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_CoreDump_core
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,13 @@
package com.baeldung.dumps;
public class CoreDump {
static {
System.loadLibrary("nativelib");
}
public static void main(String[] args) {
new CoreDump().core();
}
private native void core();
}

View File

@ -0,0 +1,19 @@
package com.baeldung.dumps;
import java.util.ArrayList;
import java.util.List;
public class HeapDump {
public static void main(String[] args) {
List<Integer> numbers = new ArrayList<>();
try {
while (true) {
numbers.add(10);
}
} catch (OutOfMemoryError e) {
System.out.println("Out of memory error occurred!");
}
}
}

View File

@ -0,0 +1,18 @@
package com.baeldung.dumps;
public class ThreadDump {
public static void main(String[] args) {
longRunningTask();
}
private static void longRunningTask() {
for (int i = 0; i < Integer.MAX_VALUE; i++) {
if (Thread.currentThread().isInterrupted()) {
System.out.println("Interrupted!");
break;
}
System.out.println(i);
}
}
}