std::bad_alloc

This is a discussion on std::bad_alloc within the C++ Programming forums, part of the General Programming Boards category; Could someone explain what this means: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted The program inserts ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    43

    std::bad_alloc

    Could someone explain what this means:
    terminate called after throwing an instance of 'std::bad_alloc'
    what(): std::bad_alloc
    Aborted

    The program inserts rows into a matrix represented as 1D vector. It works for smaller instances of the problem, but
    on larger instances, this is thrown. Does it lack a memory?

  2. #2
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Yes.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    43
    Quote Originally Posted by Brafil View Post
    Yes.
    That was very elaborate. Anyone else?

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Quote Originally Posted by onako View Post
    That was very elaborate. Anyone else?
    You asked a yes or no question so don't expect a paragraph explanation.

    Just to "elaborate", yes, the machine or way that you are allocating cannot allocate the memory, in other words, it's not available.

  5. #5
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    xD It means you probably ran out of memory. Larger instances, as you called them, require simply more memory, more than you have.
    Beware, if you allocate the "things" more than once, memory consumption will grow much faster. delete the ones that you don't need. For any else advice, you can post snippets of your code here.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21