Re: crash when run out of memory

From: Ali Çehreli (acehreli_at_yahoo.com)
Date: 11/06/04


Date: Fri, 5 Nov 2004 15:17:24 -0800


"jy" <jy_austin@yahoo.com> wrote in message
news:fa63e07d.0410291311.1239979c@posting.google.com...
> I have a C++ program which is "purify" clean, but crashes (called
terminate)
> when run out of memory on linux 2.4.27. From the core file, the crashes
happen
> after I throw an exception (after malloc returns null),

I think it is new that throws the exception, not you. new is likely
using malloc internally and throwing std::bad_alloc when there is no
memory.

> and the stack winding
> was calling the destructor of a large object. What's the genearl guidlines
for
> debugging, fixing, or at least making it a graceful exit than a crash?

Catch std::bad_alloc exception in main and report it:

int main()
{
    try
    {
        /* the application code */
    }
    catch (std::bad_alloc const &)
    {
        cout << "no memory\n";
    }
}

Ali



Relevant Pages

  • Re: Combined usage of exception handling
    ... handler will let the exception go to the defaul SEH, ... >locations in memory that can contain garbage at this point. ... For the crashes we see in the real world (after alpha and beta ... does not cause a system failure. ...
    (microsoft.public.vc.language)
  • Re: crash when run out of memory
    ... From the core file, the crashes happen ... > after I throw an exception (after malloc returns null), ...
    (comp.lang.cpp)
  • crash when run out of memory
    ... I have a C++ program which is "purify" clean, but crashes ... when run out of memory on linux 2.4.27. ... From the core file, the crashes happen ...
    (comp.lang.cpp)
  • Re: Application Errors - Tried EVERYTHING - PLEASE HELP!!!!
    ... The memory in this case passed Memtest-like diagnostics ... The only other hardware causes of tis sort of behaviour which spring ... >I DESPERATELY NEED HELP WITH THESE CONSTANT CRASHES I HAVE ... >Any Multimedia program used for ENCODING or RENDERING ...
    (microsoft.public.windowsxp.hardware)
  • Re: How to troubleshoot bugchecks on my own?
    ... not a memory problem. ... From that exception record and context, ... execute the instruction - without a problem. ...
    (microsoft.public.win32.programmer.kernel)