It came to my attention that java.util.HashMap
produces garbage for the GC when used on my high-performance system, which basically is a selector reading from the network. Is there an alternative to java.util.HashMap
(i.e. does not even need to implement java.util.Map
, in other words, it can have its own API) that I can use that will leave no garbage behind?
GARBAGE = objects that go out of scope and will have to be collected by the GC.
For @durron597:
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
while(true) {
map.put("foo1", "bah1");
map.put("foo2", "bah2");
map.remove("foo1");
Iterator<String> iter = map.keySet().iterator();
while(iter.hasNext()) {
iter.next();
}
}
}
Now run that with -verbose:gc and see what happens... :)