Hi Experts,
Its really very strange issue in our end. In our application we have stored the map with arraylist. Sometimes if the values grows OOME is thrown.
I have searched a lot but haven't no idea to rectify this problem. So if you have anything i will try this in our end.
I have attached the sample code for we are using the way
public class JavaOutOfMemoryHandling
{
public static void main(String arg[])
{
ArrayList thresholdElements = null;
// List of data's
for (int i = 0; i < 500000; ++i)
{
HashMap threshMap = new HashMap(5);
threshMap.put("THRESHOLD", "SampleThreshold_"+i);
threshMap.put("ENTITY", "SampleEntityID_"+i);
threshMap.put("MO", "SampleMOID_"+i) ;
threshMap.put("NAME", "SampleName_"+i);
threshMap.put("DISPLAY", "SampleDisplayName_"+i);
if (thresholdElements == null)
{
thresholdElements = new ArrayList(5);
}
thresholdElements.add(threshMap);
}
// this should shrink the array back to a decent size
thresholdElements.trimToSize();
System.out.println("ArrayList :: "+thresholdElements);
}
}
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.AbstractStringBuilder.expandCapacity(Abs tractStringBuilder.java:99)
at java.lang.AbstractStringBuilder.append(AbstractStr ingBuilder.java:393)
at java.lang.StringBuffer.append(StringBuffer.java:22 5)
at java.util.AbstractCollection.toString(AbstractColl ection.java:454)
at java.lang.String.valueOf(String.java:2615)
at java.lang.StringBuilder.append(StringBuilder.java: 116)
at JavaOutOfMemoryHandling.main(JavaOutOfMemoryHandli ng.java:33)
Please give some idea to rectify OOME.
Thanks & Regards,
Karpahasundaram M.[/size]