Q:

Why program stops iterating before execution is complete in c++?

I don't know why my program stops iterating at 4298 iteration. The program does what it is suppose to do when the list contains 100 items or something like that.
this->getList() contains 5000 items. I am stress testing my program 
This is the function that causes the problem:
map<Coordinate, map<Coordinate, double>> NearestPoints::allDistances() {

map<Coordinate, map<Coordinate, double>> result = map<Coordinate, map<Coordinate, double>>();

int count = 0;

list<Coordinate> list1 = this->getList();

for (list<Coordinate>::iterator iterator1 = list1.begin(), end = list1.end(); iterator1 != end; iterator1++)
{

    cout << ++count << endl;

    Coordinate coordinate1 = *iterator1;

    result.insert(make_pair(coordinate1,map<Coordinate,double>()));

    list<Coordinate> list2 = this->getList();

    list2.remove(coordinate1);

    for (list<Coordinate>::iterator iterator2 = list2.begin(), internalEnd = list2.end(); iterator2 != internalEnd; iterator2++)
    {
        Coordinate coordinate2 = *iterator2;

        /*
        if (result.find(coordinate2) != result.end())
        {
            result.at(coordinate1).insert(make_pair(coordinate2, result.at(coordinate2).at(coordinate1)));

        }
        */

        //else
        //{
            result.at(coordinate1).insert(make_pair(coordinate2, this->distanceBetweenTwoPoints(coordinate1.getX(),coordinate1.getY(),coordinate2.getX(),coordinate2.getY())));
        //}
    }
}
return result;

}

A:

You're running out of memory.  You have 5000 entries in the list.  You have a map to a map of those entries, for 5000 * 5000 map entries, or 25M.  Each map entry consists of the 24 bytes for the key (Coordinate), 8 bytes for the value (double), plus several pointers for the left, right, and parent nodes in the map.  That's at least 44 bytes for each node, with each of the 25M nodes having additional overhead for the memory allocation.

