How are these code snippets different from each other:
Snippet 1: HashMap map1= abc() ;
Snippet 2: HashMap map2= new HashMap();
map2 = abc();
I'm getting OutOfMemoryError in my application. Can the reason of this error due to the implementation of Snippet 1 in my code?
Edit: Added implementation of abc()
public HashMap abc(){
HashMap rMap = null;
StringBuffer sQuery = new StringBuffer("");
sQuery.append(" SELECT DISTINCT ABC ,DEF, ");
sQuery.append(" XYZ, ID, NAME ");
sQuery.append(" FROM TABLE1");
Query query = new Query( sQuery.toString());
List rList = query.executeSelect();
if (rList != null && rList.size() > 0) {
Iterator listIter = rList.iterator();
Map map = null;
rMap = new HashMap();
while (listIter.hasNext()) {
map = (HashMap) listIter.next();
String key = map.get("ABC") + "%"+ map.get("DEF")+"%"+map.get("XYZ");
if( rMap.containsKey(key)){
LinkedHashMap sMap = (LinkedHashMap) rMap.get(key);
sMap.put(map.get("ID"), map.get("NAME"));
rMap.put(key, sMap);
}else{
LinkedHashMap sMap = new LinkedHashMap();
sMap.put(map.get("ID"), map.get("NAME"));
rMap.put(key, sMap);
}
}
}
return rMap;
}