Skip to content

Instantly share code, notes, and snippets.

@LIttleAncientForestKami
Created June 30, 2015 06:52
Show Gist options
  • Save LIttleAncientForestKami/cb03798d3c0bda39dcbd to your computer and use it in GitHub Desktop.
Save LIttleAncientForestKami/cb03798d3c0bda39dcbd to your computer and use it in GitHub Desktop.
OOM flavours, side gist for OOM-diag checklist, with thanks from Plumbr: https://plumbr.eu/outofmemoryerror/java-heap-space
/**
* Run with Heap set to 12MB and 13MB respectively
* Thanks Plumbr
*/
class OOM {
static final int SIZE=2*1024*1024;
public static void main(String[] a) {
int[] i = new int[SIZE];
}
}
/**
* Equals... thanks Plumbr.
*/
class KeylessEntry {
static class Key {
Integer id;
Key(Integer id) {
this.id = id;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
public static void main(String[] args) {
Map m = new HashMap();
while (true)
for (int i = 0; i < 10000; i++)
if (!m.containsKey(new Key(i)))
m.put(new Key(i), "Number:" + i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment