Skip to content

Instantly share code, notes, and snippets.

@zhuyifan2013
Created February 3, 2020 07:23
Show Gist options
  • Save zhuyifan2013/88041f771c954ac443595094dbcaf643 to your computer and use it in GitHub Desktop.
Save zhuyifan2013/88041f771c954ac443595094dbcaf643 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
import java.util.List;
/**
* VM options: -Xms2m -Xms2m -XX:+HeapDumpOnOutOfMemoryError
*/
public class HeapOOM {
static class EObject{
private byte[] myBytes = new byte[200*1024];
}
public static void main(String[] args) {
List<EObject> list = new ArrayList<>();
while (true) {
list.add(new EObject());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment