Skip to content

Commit 6f1e14b

Browse files
veontomoKevinGilmore
authored andcommitted
Code for article BAEL-2386 (eugenp#5958)
* Add code for the article 'Java Primitives versus Objects' * Use JMH for benchmarking the primitive and wrapper classes * Uncomment the benchmarks and remove unused class * Add a binary search tree implementation * Add an example of how to use the binary tree class * Adjust the print statements * Add a code for article #BAEL-2386
1 parent e4dd6e0 commit 6f1e14b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.baeldung.flightrecorder;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* Simple program that illustrates how to use Java Flight Recorder.
8+
*
9+
* This programs creates a list, inserts objects in it until
10+
* an OutOfMemoryError is thrown.
11+
*
12+
*/
13+
public class FlightRecorder {
14+
15+
public static void main(String[] args) {
16+
List<Object> items = new ArrayList<>(1);
17+
try {
18+
while (true) {
19+
items.add(new Object());
20+
}
21+
} catch (OutOfMemoryError e) {
22+
System.out.println(e.getMessage());
23+
}
24+
assert items.size() > 0;
25+
try {
26+
Thread.sleep(1000);
27+
} catch (InterruptedException e) {
28+
System.out.println(e.getMessage());
29+
}
30+
}
31+
32+
}

0 commit comments

Comments
 (0)