Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Listing 1
JAVA PROFILE 1.0.1, created Sat Feb 14 07:07:45 2009
…
THREAD START (obj=5ecd1b8, id = 1, name="Signal dispatcher",
group="system")
THREAD START (obj=5ecd318, id = 2, name="Reference Handler",
group="system")
THREAD START (obj=5ef2ee0, id = 3, name="Finalizer",
group="system")
THREAD START (obj=5ef2fc0, id = 4, name="GC Helper 1",
group="system")
THREAD START (obj=3c7820, id = 5, name="main", group="main")
THREAD START (obj=5f5feb8, id = 6, name="DG event write
thread", group="system")
TRACE 4:
java/lang/ref/Reference.process(Reference.java:Native method)
java/lang/ref/Reference.access$300(Reference.java:54)
java/lang/ref/Reference$ReferenceHandler.run(Reference.java:
135)
TRACE 6:
java/lang/Object.wait(Object.java:Compiled method)
java/lang/ref/ReferenceQueue.remove(ReferenceQueue.java:14
4)
java/lang/ref/ReferenceQueue.remove(ReferenceQueue.java:16
0)
java/lang/ref/Finalizer$FinalizerThread.run(Finalizer.java:225)
…
HEAP DUMP BEGIN (333 objects, 97716 bytes) Sat Feb 14 07:08:15
2009
ROOT 5ef2ee0 (kind=<thread>, id=3, trace=6)
ROOT 5ecd318 (kind=<thread>, id=2, trace=7)
…
ROOT 607fd58 (kind=<system class>,
name=HeapExhaustionSimulator)
…
CLS 607fd58 (name=HeapExhaustionSimulator, trace=0)
super
5e2aba8
loader
domain
constant[3]
constant[5]
constant[9]
constant[10]
60a2490
60a9590
5f5f2f8
5dcfca0
607fd58
5e2aba8
…
ARR 60a9a30 (sz=44, trace=0, nelems=20, elem type=char)
OBJ 5ef2ee0 (sz=76, trace=0,
class=java/lang/ref/Finalizer$FinalizerThread@5ef2ea0)
name
60a9990
group
60a95d0
inheritedAccessControlContext
5ecd158
…
HEAP DUMP END
Listing 2
JVMDBG001: malloc failed to allocate 1004096 bytes, time: Sat Feb
28 08:37:12 2009
JVMDBG001: malloc failed to allocate 1004096 bytes, time: Sat Feb
28 08:37:12 2009
JVMDBG001: malloc failed to allocate 1004096 bytes, time: Sat Feb
28 08:37:12 2009
JVMDBG001: malloc failed to allocate 1004096 bytes, time: Sat Feb
28 08:37:13 2009
JVMDBG001: malloc failed to allocate 1004096 bytes, time: Sat Feb
28 08:37:15 2009
Exception in thread "main" java.lang.OutOfMemoryError: Unable to
allocate 1000000 bytes of direct memory after 5 retries
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:141)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:240)
at
NativeMemorySimulator.main(NativeMemorySimulator.java:11)
Caused by: java.lang.OutOfMemoryError: JVMCI046:
allocateMemory failed
at sun.misc.Unsafe.allocateMemory(Native Method)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:128)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:240)
at
NativeMemorySimulator.main(NativeMemorySimulator.java:11)
Listing 2a: Simulation of Native Memory Exhaustion
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
* WARNING! This application could cause unexpected system failure
* Please do not run it on non-test environment
*/
import java.nio.ByteBuffer;
import java.util.ArrayList;
public class NativeMemorySimulator {
public static void main(String[] args) {
ArrayList bufferList = new ArrayList();
while(true){
bufferList.add(ByteBuffer.allocateDirect(1000000));
}
}
}
Listing 2b: Simulation of Java Heap Exhaustion
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.ArrayList;
public class HeapExhaustionSimulator {
public static void main(String[] args) {
ArrayList aList = new ArrayList();
while(true){
aList.add(new String(charArray.toString()));
aList.add(new char[1000000]);
aList.add(new int[1000000]);
}
}
}
Listing 2c
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class ClassVariableExample {
static Vector v1;
public ClassVariableExample() {
init();
}
public void init() {
v1 = new Vector();
while(true){
int[] s1 = new int[100000];
long[] s2 = new long[100000];
float[] s3 = new float[100000];
v1.add(s1);
v1.add(s2);
v1.add(s3);
}
}
}
Listing 2d
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class ClassVariableTest {
static public void main(String[] args) {
ClassVariableExample newObject = new
ClassVariableExample();
}
}
Listing 2e
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class InstanceVariableTest {
static public void main(String[] args) {
InstanceVariableExample newObject = new
InstanceVariableExample();
}
}
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class InstanceVariableExample {
Vector v1;
public InstanceVariableExample() {
init();
}
public void init() {
v1 = new Vector();
while(true) {
int[] s1 = new int[100000];
long[] s2 = new long[100000];
float[] s3 = new float[100000];
v1.add(s1);
v1.add(s2);
v1.add(s3);
}
}
}
Listing 3
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class LocalVariableTest {
static public void main(String[] args) {
LocalVariableExample newObject = new
LocalVariableExample();
}
}
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.*;
public class LocalVariableExample {
public LocalVariableExample() {
init();
}
public void init() {
Vector v1 = new Vector();
While(true) {
int[] s1 = new int[100000];
long[] s2 = new long[100000];
float[] s3 = new float[100000];
v1.add(s1);
v1.add(s2);
v1.add(s3);
}
}
}
Listing 4
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
* WARNING! This application could cause unexpected system failure
* Please do not run it on non-test environment
*/
import java.util.ArrayList;
public class NativeMemoryExhaustionSimulator {
public static void main(String[] args) {
while(true){
Thread thread = new Thread(){
public void run() {
try {
while (true) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
thread.start();
}
}
}
Listing 5
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.ArrayList;
public class HeapExhaustionSimulator {
public static void main(String[] args) {
ArrayList aList = new ArrayList();
while(true){
aList.add(new String(charArray.toString()));
aList.add(new char[1000000]);
aList.add(new int[1000000]);
}
}
}
Listing 6
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
import java.util.LinkedList;
public class VerticalMemoryLeakSimulator {
public static void main(String[] args) {
String t = "";
for (int i = 0; i < 20; i++) {
t += t + i;
}
LinkedList lList = new LinkedList();
long counter = 0;
while (true) {
lList.add("value=" + counter + t);
counter++;
}
}
}
Listing 7
/*
* Author : Jinwoo Hwang
* (C) Copyright IBM Corp. 2009. All Rights Reserved
*/
public class DiagonalLeakGenerator {
protected void finalize() throws Throwable {
Thread.yield();
}
}
public class DiagonalMemoryLeakSimulator {
public static void main(String[] args) {
while(true){
DiagonalLeakGenerator d1 = new
DiagonalLeakGenerator();
}
}
}