C++ program dies with std::bad_alloc, BUT valgrind reports no memory leaks
问题 My program fails with 'std::bad_alloc' error message. The program is scalable, so I've tested on a smaller version with valgrind and there are no memory leaks. This is an application of statistical mechanics, so I am basically making hundreds of objects, changing their internal data (in this case stl vectors of doubles), and writing to a datafile. The creation of objects lies inside a loop, so when it ends the memory is free. Something like: for (cont=0;cont<MAX;cont++){ classSection seccion;