Re: throwing out of memory exception in c++ doesnt work

From: Leor Zolman (leor_at_bdsoft.com)
Date: 03/01/04


Date: Mon, 01 Mar 2004 13:24:47 GMT

On Mon, 01 Mar 2004 06:08:18 GMT, Stephan
<stephas@frogking.stephas.homelinux.org> wrote:
>On Mon, 01 Mar 2004 05:41:20 +0000, Leor Zolman wrote:

>> If you're not allocating much memory and your program crashes, I doubt the
>> crash is related to exhaustion of the free store! Pointer bug? Have a
>> debugger you can fire up and trace through the program with? Why do you
>> think the issue is dynamic-memory-allocation-failure related?
>
>gdb just tells me:
>Program terminated with signal SIGKILL, Killed.
>I didnt kill it and gdb doesnt report a line number, and gtkrellm shows
>that my memory is filling up until the SIGKILL interrupts.

Good, intuitive debuggers can be hard to find on Unix...but there's always
good 'ole cerr. As a last resort I begin putting in trace statements. There
are some great tricks for doing that sort of thing in the Eckel/Allison
book I cited. You need a better handle on where the code is when it
crashes.

>I am pretty familiar with the above, and I meant the actual exception data
>type you wrote here:
>> catch (const exception &e)
>I think this is the type for any OS thrown exceptions, since you can throw
>your own int, char, whatever ones. I guess I answered my own question.

Yeah, basically all standard exceptions derive from "exception"; in this
case I did that to gain access to the what() member function. If I didn't
care about that, I would probably just have used catch(...)
        -leor

>
>However I am still unsure about why I get a SIGKILL ! If I leave your try
>and catch block out and dont throw the bad_alloc(), I ll be stuck in an
>endless loop but I can't even see that more memory is used in gtkrellm,
>which shows how much memory is currently in use.
>thanks
>stephan

Leor Zolman
BD Software
leor@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
           Decryptor at www.bdsoft.com/tools/stlfilt.html



Relevant Pages

  • Re: MyString Class
    ... > I compiled your program and run it under the debugger. ... > The first crash happens in ... ... > memory is flawed. ... First bug fixed. ...
    (comp.lang.cpp)
  • RE: Memory increasing even when in debug-break
    ... there are 2 types of memory leak in .Net: ... More interesting is the debugger breaks while memory still increasing ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.debugging)
  • Re: how can I create minidumps of second chance exceptions in .NET 1.1 managed code?
    ... Using the configuration like you suggested sends the exception to the JIT debugger which is registered in a system-wide manner, and I don't want to register there. ... ADPlus is usually good in catching 2nd chance managed exceptions." ...
    (microsoft.public.vsnet.debugging)
  • Re: Question about workitem.
    ... I set SynchronizationScope to WdfSynchronizationScopeNone. ... A fatal system error has occurred. ... Debugger entered on first try; Bugcheck callbacks have not been invoked. ... Invalid system memory was referenced. ...
    (microsoft.public.development.device.drivers)
  • Re: blue screen error - Symbols can not be loaded...
    ... What version, if any, of Daemon Tools do you have installed? ... Enquire, plan and execute ... These types of error can always be down to bad memory. ... Your debugger is not using the correct symbols ...
    (microsoft.public.windowsxp.general)