fork download
  1. #include <iostream>
  2. #include <new>
  3.  
  4. int main()
  5. {
  6. try {
  7. while (true) {
  8. new int[100000000ul];
  9. }
  10. } catch (const std::bad_alloc& e) {
  11. std::cout << "Allocation failed: " << e.what() << '\n';
  12. }
  13. }
Success #stdin #stdout 0s 1176576KB
stdin
Standard input is empty
stdout
Allocation failed: std::bad_alloc