[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: About memory allocation failures....
From:       Kuba Ober <kuba () mareimbrium ! org>
Date:       2002-02-04 18:11:13
[Download RAW message or body]

> > Running out of memory doesn't happen during malloc/new. It happens when
> > the OS tries to allocate a physical page to back virtual memory that has
> > already been given to you via malloc/new. This happens when you first
> > access the memory that malloc/new has returned. The OS responds by
> > sending you a SIGSEGV. Your program never gets to see an allocation
> > failure. In fact, my experience with Linux has been that the user gets
> > bored of the swapping and resets the computer /long/ before swap space is
> > exhausted.
> >
> > The only way out of this is to turn overcommit off in your OS. Not many
> > OSs can do this (neither Linux or FreeBSD is one). It's also not usually
> > a very useful thing to do most of the time.
>
> 	Yes youre right, so i think i'll be removing the NULL returning checks
> from my apps, well all that they taught me at school about always checking
> for malloc/new was pointless afther all.....or well not that bad as i
> supose its good programming practice but of course with a little
> performance
> penality....

That's what happens when people are taught programming in say Borland Pascal 
under DOS - checking for memory allocation failures in that kind of 
environment is actually needed and to the point, and a good practice.

Then the get to work under VM systems, like linux, especially those which 
have no trivial way to disable memory overcommitting - and in that real life 
situation what they have been taught is actually pointless. Notice that these 
(VM) systems include Win32 architecture only to some extent - windows kernel 
together with msvc/borland libraries seem to be trying to be "intelligent" at 
times and malloc's/new's can fail at times - it's hopeless then anyway, and 
typically it's the library which tries to do a good job and catch the CPU 
exception generated by the OS vmm.

Alas, as a rather dirty trick for those of you using Windows and M$ Office 
suite: if your non-office app complains of out-of-memory condition, just kill 
OSA (ctrl-alt-del, select OSA, click Close) - this seems to reclaim a few 
megabytes which can allow you to finish your work and reboot cleanly. Ouch, 
that was completely off topic, I know...

Cheers, Kuba
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic