mirror of
https://github.com/Noratrieb/UselessClasses.git
synced 2026-01-14 08:35:10 +01:00
30 lines
890 B
Java
30 lines
890 B
Java
package com.github.nilstrieb.uselessclasses;
|
|
|
|
/**
|
|
* This class tries to create a huge array of longs (1e+22 in total)
|
|
* This obviously causes an {@code OutOfMemoryError}
|
|
*
|
|
* And while the docs of {@code Error} say that an Error shows "problems that a reasonable application
|
|
* should not try to catch", nothing is actually stopping us from doing it.
|
|
*
|
|
* Welcome to Hell.
|
|
*/
|
|
public class Hell {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
boolean success = false;
|
|
|
|
while (!success) {
|
|
try {
|
|
var y = new long[100][100][100][100][100][100][100][100][100][100][100];
|
|
success = true;
|
|
} catch (OutOfMemoryError e) {
|
|
e.printStackTrace();
|
|
}
|
|
System.out.println("creation of massive long array failed. trying again...");
|
|
}
|
|
|
|
System.out.println("Sucess!");
|
|
}
|
|
}
|