Hi I've been having this problem for a while. It seems that every time I try to use the add method on an ArrayList to insert an object into the list I get an error stating "out of memory...heap overrun". I would understand if these lists were large and the objects contained within then were complex but neither is the case. Here is the code snippet that causes the problem. Thanks in advance for any insight!
ResultObject ro = new ResultObject(str, distance);
if(res_.isEmpty()) res_.add //Places first object in the arrayList
else
{
for(int i =0; i<res_.size();i++) //walks through the arrayList
{
if(distance < res_.get(i).getDistance()) //This statement attempts to order the arrayList at time of entry by comparing the current result to the value in the arrayList
{
res_.add(i,ro) //This is the statement that causes the memory overrun!
added = true;
}
}
if(!added) //adds the object to the end of the list if it was not inserted above.
{
res_.add(ro)
added = false;
}
}