Old Wolf napisal(a):
pit3k wrote: mlimber napisal(a): pit3k wrote:
My program tries to call the vector::push_back(...) member
function in a loop couple dozen milion times, which is what I
expect. After about 20 millions successfull push_back() calls
the program abnormally aborts with a core dump.
First, I meant std::list, not std::vector. It shouldn't change much
though.
[SNIP]
Please post a COMPLETE program that compiles correctly, and
demonstrates the problem. Then, someone here will be able
to give you an exact answer as to what is going on.
OK, I've just used GNU g++ compiler instead of HP aCC.
The results:
g++ version throws std::bad_alloc exception, when it's memory usage (as
shown by top) reaches 953MB.
aCC version core dumps with "Bus error" when memory usage reaches
870MB.
Does that mean that HP compiler / STL implementation is broken or is
the core dump behaviour also valid?
Results were obtained using the following test program:
#include <list>
#include <iostream>
int main()
{
std::list<int> buffer;
try
{
for(;;)
buffer.push_back(0);
}
catch (std::bad_alloc &e)
{
std::cerr << "Memory allocation error" << std::endl;
}
catch (...)
{
std::cerr << "Unknown exception" << std::endl;
}
return 0;
}