BAEL-2386: Moved FlightRecorder from core-java to core-java-perf

This commit is contained in:
eric-martin
2019-01-07 20:32:55 -06:00
parent 1fdf586336
commit ea1a467892

View File

@@ -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());
}
}
}