As far as I know, there are three reasons why a std::bad_alloc can be thrown:
We have code which runs into a std::bad_alloc, but none of the above reasons seem to apply. The datastructure is a graph stored as a std::list of vertices, where each vertex stores again a std::list of the edges of which it is part of as well as some amount of contiguous data.
For small graphs (<= 100'000 vertices), the program runs perfectly fine, irrespective of how large the data sections per vertex are (we can without problems allocate up to 40 GB in total). If the number of vertices grows larger, however, we get a std::bad_alloc exception thrown even on instances using "only" 8 GB of memory.
Since there are no problems when allocating more memory in larger blocks, above reasons 1. and 2. should be ruled out. There are sections where we play around with pointers in a quite error prone way, so it is possible that we might corrupt the heap datastructure. But when run on smaller instances, valgrind's memcheck reports our code as flawless, so that reason seems unlikely as well (on throwing instances, valgrind itself runs out of memory, so we cannot check that case directly).
Are there any ideas on what else could be the reason for this behaviour, or what tests we might run to further pin down the problem?
OS: Fedora 19
Build system: cmake with gcc 4.8.2
std::bad_alloc is a type of exception that occurs when the new operator fails to allocate the requested space. This type of exception is thrown by the standard definitions of operator new (declaring a variable) and operator new[] (declaring an array) when they fail to allocate the requested storage space.
Throwing std::bad_alloc represents a failure to process a given allocation request for any reason. One such reason is that the requested memory size exceeds a per-allocation limit specified in the system for a given program.
std::bad_alloc is the type of the object thrown as exceptions by the allocation functions to report failure to allocate storage.
A terminate called after throwing an instance of 'std::bad_alloc' is a memory-related error in a programming language C++. What causes the error is a difficult one to track down because it depends on many factors. However, you don't have any reasons for alarm because we have identified the causes.
I cannot comment on your post, so I'll put it in reply.
I came across the same problem while using OpenFST with Kaldi (same system and gcc as yours). I didn't track the exact origin of this issue, but it seems, that kernel 3.12 is the issue here. I booted with one of the backup kernels (one of 3.11 series) and the problem was gone.
You can use:
yum list --showduplicates kernel
to find available 3.11 kernel.
EDIT:
It seems, that this bug is fixed in Kernel 3.12.11-201 and in 3.13+
Source: Bugzilla
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With