Is "bad_aloc" a program issue or a resource issue in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is "bad_aloc" a program issue or a resource issue in c++?

15th Apr 2022, 2:05 AM
Mohammed
1 Answer
+ 1
bad_alloc can also be thrown when you have a bug that is overwriting the pointers that the heap uses to manage the pool of memory that it uses to allocate from. The most common cause of that is that you are writing past the end of an allocated block of memory, (or before the start, but that's less common).
15th Apr 2022, 4:33 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar