Let's say I have a Map. I added a couple of elements, processed those elements and now I no longer need those elements. Should I call Map#clear(); method or just let garbage collector do its job? Does cleaning the map reduces GC pressure?
Here is a sample code:
public void process() {
Map<String, Object> myMap = new LinkedHashMap<>();
myMap.put("CatA", "Meow1");
myMap.put("CatB", "Meow2");
doSomeProcessing(myMap);
myMap.clear();
}
P.S- This operation will be done around 10K times per second.