Code for article BAEL-2386 (#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
This commit is contained in:
parent
e4dd6e0b6a
commit
6f1e14b649
|
@ -0,0 +1,32 @@
|
|||
package com.baeldung.flightrecorder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Simple program that illustrates how to use Java Flight Recorder.
|
||||
*
|
||||
* This programs creates a list, inserts objects in it until
|
||||
* an OutOfMemoryError is thrown.
|
||||
*
|
||||
*/
|
||||
public class FlightRecorder {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Object> items = new ArrayList<>(1);
|
||||
try {
|
||||
while (true) {
|
||||
items.add(new Object());
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
assert items.size() > 0;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue