C ++ program dies with std :: bad_alloc, but valgrind reports no memory leaks

My program crashes with the error message "std :: bad_alloc". The program is scalable, so I tested a smaller version with valgrind and there were no memory leaks.

This is an application of statistical mechanics, so I basically do hundreds of objects, changing my internal data (in this case, stl vectors of twins) and writing to a data file. Creating objects lies inside the loop, so when it ends, memory is free. Sort of:

for (cont=0;cont<MAX;cont++){
         classSection seccion;
         seccion.GenerateObjects(...);
         while(somecondition){
                seccion.evolve();
                seccion.writedatatofile();
         }}

So, there are two variables that set the program calculation time, the size of the system, and the number of runs. There is only a crash for large systems with many runs. Any ideas on how to catch this memory issue?

Thank,

+3
2

, , , .

:

  • , ( )
  • a
+3

valgrind , , valgrind.

, Java. , , , , (, - ). , .

- , .

, , , std:: deque, std::vector, , .

+3

Source: https://habr.com/ru/post/1779150/


All Articles