Crashea program from nowhere C ++ [closed]

0

I have a problem with a software developed in C ++, I was many things and being running for 2 or 3 hours the program produces error and closes, the error that shows me is the following but I can not understand what is ...

    
asked by Ignacio Copparoni 20.10.2018 в 07:22
source

1 answer

5

From cppreference.com

  

std :: bad_alloc

     


std::bad_alloc is the type of the object thrown as exceptions by the allocation functions to report failure to allocate storage.

Which, in free translation and summary, comes to say that your program has run out of memory .

This exception is thrown by operator new as well as operator new[] when it can not satisfy the request.

It is not 100% safe, since it can be launched by thrown anywhere in the code.

The real solution is to examine your program: it usually indicates that you are leaving pieces of memory without releasing (calling delete or delete[] ). It can also occur in normal , because you are working with such a large amount of data that the system is unable to satisfy your demands.

Also, keep in mind that it can also occur even if it is not you who launches it (any C ++ library you are using), or because the real culprit is a piece of code in C that does not make the appropriate calls to free( ) . Although this will not throw the exception (C has no exceptions), you can use so many resources that calls after new in your code fail and generate the exception.

What you can do in these cases: start to carefully review your call logics to new and delete : -)

    
answered by 20.10.2018 / 08:41
source