i know "a"
and new String("b")
both will create "a"
or "b"
in constant pool
But why the following program doesn't throw outOfMemoryError
?
Does new String("b")
create nothing in constant pool?
List<String> s = new ArrayList<String>();
// -XX:PermSize=5M
// -XX:MaxPermSize=5M
// why no oom:pergen space throw???? "i" isn't in constant pool????
for (;;) {
for (int i = 0; i < 1000000; i++) {
s.add(new String("" + i));
}
}