From: Martin B. on
Mathias Gaunard wrote:
> On 29 avr, 20:04, Andre Kaufmann <akfmn...(a)t-online.de> wrote:
>
>> There should be always a line of code, where the developer
>> hasn't thought about insufficient memory and if the program doesn't
>> crash, at least it will have unpredicted behavior or data loss.
>
> All code should be basic exception-safe, so unpredicted behavior
> shouldn't be possible; whatever happens invariants are maintained and
> the program remains in a valid state.
> Note basic exception-safe is guaranteed by the use of RAII.
>

Well. Yes. Should.

I agree with Andre, that - quote: "IMHO 99,9% of all C++ applications, can't recover 100% correctly from memory insufficiency under all conditions".

It would be interesting to see some tests conducted on a popular set of C++ AND C applications (this could range from MS-Office to simple grep or other cmdline tools) and see what happens to them under artificial low memory conditions(*).
I would predict a very high crash / abort ratio.

Maybe someone has a resource where this has been done?

br,
Martin


(*): Note that I have no clue how such artificial conditions could be created for a running process. I guess one would somehow have to limit the total amount allocable for a single running process.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]