3 billion items in Java Map with 16 GB RAM One rainy evening I meditated about memory managment in Java and how effectively Java collections utilise memory. I made simple experiment, how much entries can I insert into Java Map with 16 GB of RAM? Goal of this experiment is to investigate internal overhead of collections. So I decided to use small keys and small values. All tests were made on Linux 64bit Kubuntu 12.04. JVM was 64bit Oracle Java 1.7.0_09-b05 23.5-b02 . There is option to use compressed pointers (-XX:+UseCompressedOops), which is on by default on this JVM. First is naive test with java.util.TreeMap . It inserts number into map, until it runs out of memory and ends with exception. JVM settings for this test was -Xmx15G import java.util.*; Map m = new TreeMap(); for(long counter=0;;counter++){ m.put(counter,""); if(counter%1000000==0) System.out.println(""+counter); } This example ended at 172 milion entries.
Read full article from kotek.net
No comments:
Post a Comment