"main" java.lang.OutOfMemoryError in Hashtable sorting and reversing -
i trying sort arraylist of hashtable (arraylist>). hastable has 3345588 entries. when tried sort , assign reverse order in hastable found
exception in thread "main" java.lang.outofmemoryerror @ java.util.hashtable.newentry(hashtable.java:91) @ java.util.hashtable.put(hashtable.java:766)
my code below
public static hashtable<string, integer> sortvalue( hashtable<string, integer> t) { // transfer list , sort arraylist<map.entry<string, integer>> l = new arraylist<entry<string, integer>>( t.entryset()); hashtable<string, integer> f = new hashtable<string, integer>(); collections.sort(l, new comparator<map.entry<string, integer>>() { public int compare(map.entry<string, integer> o1, map.entry<string, integer> o2) { return o1.getvalue().compareto(o2.getvalue()); } }); // create new normalized hashtable index started 1 // frequent key int = 1; (int = l.size(); > 0; i--) { f.put(l.get(i - 1).getkey(), a);// getting error here a++; } // system.out.println(l); return f; }
you can try increase vm memory when running program. can read here vm memory setting how in details. sample:
java -xms1024m -xmx4096m com.sample.helloworld
Comments
Post a Comment