I was timing the following loop:
public static void main(String[] args) {
long time = System.currentTimeMillis();
List<Hashtable> objects = new ArrayList<Hashtable>(10000000);
for (int i = 10000000; i > 0; i--) {
objects.add(new Hashtable());
}
System.out.println(System.currentTimeMillis() - time);
}
In JDK 1.6.0_33 it takes around 2500 ms every time. Switching to JDK 1.7.0_25 it takes 5600 ms.
The same with just doing new Hashtable(), without adding it to a list: Java 1.6: 60 ms, Java 1.7: 460 ms.
This looks strange, did something deteriorate in Java7, did the internals of Hashtable become more complex, or am I just missing something?