I know there all lot of questions on java.lang.OutOfMemoryError: Java heap space
.
like question 1
But none of the links are not proper answers to my question.
We are generating reports in spreadsheet format, where huge data is coming from database side. We increased the heap memory size from 2 GB to 4 GB, no use.
May be because of some extra space in database column, so I trimmed all the getters
and setters
using trim()
method, this is also no use.
For Example :
String s = "Hai ";
s.trim();
If any one having how to resolve this issue from Java coding side, without increasing the size of the heap space. Because client told, they will not increase the heap space any more.
When calling this method getting exception
private CrossTabResult mergeAllListsSameNdc(CrossTabResult crt, CrossTabResult res) {
crt.setFormularyTier(crt.getFormularyTier()==null ? "":((crt.getFormularyTier().contains(crt.getListId())? crt.getFormularyTier(): crt.getListId()+crt.getFormularyTier()) +"~"+res.getListId()+res.getFormularyTier()));
crt.setFormularyTierDesc(crt.getFormularyTierDesc()==null ? "":((crt.getFormularyTierDesc().contains(crt.getListId())? crt.getFormularyTierDesc(): crt.getListId()+crt.getFormularyTierDesc()) +"~"+res.getListId()+res.getFormularyTierDesc()));}
Can't share more code, due to confidential. By looking above code, if you people have any alternative solution means inform me. We are merging two String
based on the same id
.