Questions tagged [bad-alloc]

std::bad_alloc is the type of exception thrown when memory allocation fails in a C++ program

In C++ when operator new or std::allocator cannot allocate memory an exception of type std::bad_alloc will be thrown.

265 questions
1
vote
2 answers

How to resolve a bad_alloc that seems unlikely to be an out-of-memory issue?

I'm writing a bit of code for searching a maze with BFS in C++ (my primary language is Python, but I wanted to excersise my C++ brain a bit...), and I stumbled across this strange error. Here are the relevant data structures: struct Maze { …
mrdmnd
  • 91
  • 1
  • 8
1
vote
2 answers

Bad allocation with list

I have this virtual method: const string& my_class::to_string() const { string str(this->name + string(" ")); if(!this->children.empty()) { for(const std::shared_ptr e : this->children) …
Nick
  • 10,309
  • 21
  • 97
  • 201
1
vote
3 answers

why does dynamic memory allocation fail after 600MB?

i implemented a bloom filter(bit table) using three dimension char array it works well until it reaches at a point where it can no more allocate memory and gives a bad_alloc message. It gives me this error on the next expand request after allocating…
John
  • 794
  • 2
  • 18
  • 34
0
votes
2 answers

How to resolve this bad_alloc problem?

I'm developing an application that needs to interact over FTP. For this communication I am currently using C++, Visual Studio and Poco on Windows. The following line results in a bad_alloc exception... ftp = new FTPClientSession("127.0.0.1",…
Tamara Wijsman
  • 12,198
  • 8
  • 53
  • 82
0
votes
0 answers

Biomod2 - 'Error in { : task 1 failed - "std::bad_alloc"' appears when reaching the "Do Single Models Projection" of BIOMOD_EnsembleModeling()

I've been attempting to project the habitat suitability for Cassava across Africa using presence data from GBIF (about 5000 records) in Biomod2 in R. I am using a set of 26 environmental variables, including CHELSA bioclimatic variables, topographic…
yam
  • 1
0
votes
0 answers

Why does snarkjs running on Node.js throw an instance of std::bal_alloc?

I'm running snarkjs over Node.js on a linux x64 machine with 256GB RAM and I have a zk-SNARK circuit composed by ~28M constraints. I want to execute the command snarkjs zkey new to generate a zkey file from a circuit compiled with circom, but when…
0
votes
0 answers

std::bad_alloc errors when working with two rasters - want to combine them & analyse the data

I have two rasters: forest class; and fire frequency. They are of the same study area. I want to combine them into a data frame so I can run data analyses. I have been able to combine them with: class_data <- c(class, data) but converting to a data…
0
votes
0 answers

Error: std::bad_alloc for no apparent reason

I've got the Error: std::bad_alloc error when trying to use a for loop: trees <- as.multiPhylo(for ( i in 1:100 ) { rand_tip(my.input, tree, forceultrametric = TRUE, prune = FALSE) }) The weird thing is, I used the rand_tip function before without…
brena
  • 1
0
votes
0 answers

bad alloc with admixture32?

I'm having a problem calculating delta K with the admixture32 pipeline on my RADseq data generated by STACKS. Here is the command I use: #!/bin/bash #SBATCH -J mpi_job #SBATCH --nodes=1 #SBATCH --time=80:00:00 #SBATCH --cpus-per-task=10 #SBATCH…
Loïs V
  • 33
  • 3
0
votes
1 answer

Node child_process can't pipe stdout when the child process gets aborted

I want to compile code (pawn language), pipe all the compiler output, and then match all diagnostics using regex. The thing is, for some reason, the compiler sometimes crashes with this error: terminate called after throwing an instance of…
Mis
  • 23
  • 4
0
votes
0 answers

Allocation failed: std::bad_alloc with method using isl library methods

The following method is causing bad memory allocation exceptions, I can't seem to find where this is exactly happening, for context the method is using the isl library to construct a map containing a set of iterators names with their number of…
0
votes
0 answers

Causing system throw bad_alloc to discover possible failures

I want to discover (for debug purpose) any possible cause of memory failure of my C++ program. Should I limit the heap size? Should I infinite loop a dynamic memory allocation (new) until crash? i want to cause a bad_alloc error without throwing it…
0
votes
1 answer

TWS API reqScannerSubscription fails with std::bad_alloc

I’m using TWS API in a C++ implementation. I’m getting a bad memory allocation exception when running a market scanner. The code is designed to connect and then start a couple market scanners. Driver const unsigned MAX_ATTEMPTS = 50; const…
0
votes
0 answers

C++ program needs to much memory to run and crashes. How to avoid this?

I want to find ANY repeating combinations of k taken from n across all vector of vectors of 20 int values each. That vector of vectors is all about 50.000+ in size. For example this is the SQLite piece of code that finds all repeating combos of 5…
YoYoYo
  • 439
  • 2
  • 11
0
votes
2 answers

Searching word in a file txt file that contains 100,000,000 words in c++

I have a txt file with 100000000 words in every new line. I want to write a function that takes an input of the word and searches if the word is there or not in the txt file. I have tried this with map and trie method but I'm getting std:bac_alloc…