Created
June 30, 2015 06:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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