Memory allocation using new operator failed due to insufficient available memory.
Thrown by C++ dynamic memory allocation operators (`new` or `new[]`) when the operating system fails to fulfill a requested memory allocation.
Attempting to allocate a huge array due to integer overflow, or cumulative un-freed heap memory leaks.
1#include <iostream>2 3int main() {4 size_t huge_size = 9999999999999999ULL;5 int* ptr = new int[huge_size]; // Throws std::bad_alloc!6 delete[] ptr;7 return 0;8}1#include <iostream>2#include <new>3 4int main() {5 size_t huge_size = 9999999999999999ULL;6 try {7 int* ptr = new int[huge_size];8 delete[] ptr;9 } catch (const std::bad_alloc& e) {10 std::cerr << "Allocation failed: " << e.what() << std::endl;11 }12 return 0;13}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
Requesting multiple petabytes of contiguous heap RAM exceeds physical and virtual memory swap limits.