"John Eskie" <> wrote in message
news:3febf4a7$0$29319$ k...
> "Victor Bazarov" <> wrote in message
> news
9oGb.645301$Tr4.1654166@attbi_s03...
> > "John Eskie" <> wrote...
[..]
> There are better ways to inform users then just crashes. One would be to
> idle until it gets enough memory. After all Windows 2000 informed me at
the
> same time that it was running low on resources and graphics turned into
> fewer colors (256 colors if I remember right).
> If I write programs that are suppose to run in background without users
> interfearing the best thing I can do is to make them taking care of
> themselves. A crash will result a user having to restart it or whatever
> should be done in such a situation.
>
Most computers now use VM.
Most computers now run lots of processes concurrently.
Most computers now have many Gb of Disk therefore most computers tend to
have very large VM.
Consequently I find that the only time you run out of memory is if some
process has run amok and is unitentionally using it all.
If it is your process then waiting around for more memory or even just
holding on to what you have got is actually screwing up all the other
(possibly more important) processes - NOTHING does any useful work - Nobody
can fix it because you can't even run the task manager or equivalent.
If it is not your process but another then it too will run out of memory and
there are then two possibilities:
(1) It exits - you can then get your memory but only because it didn't
follow the same approach as you do.
(2) It follows your approach and waits for more memory. All processes in the
system do this - NOTHING does any useful work - Nobody can fix it because
you can't even run the task manager or equivalent.
> > > In my opinion it's still better to run a while() loop and stall the
> > program
> > > then having it crash instead, no?
> >
> > I am not sure what you mean by that. I get really annoyed by programs
> > that do not respond when I need them to, and have to kill them manually.
> > How is that better than crashing?
>
> It's better because it doesn't crash. Depending on the program a crash
could
> result in data loss. A idleing application which will resume when it gets
> the needed memory later on will just keep running.
If there is not enough memory to be able to run an app to kill a runaway app
then the only option is the big red button which will cause ALL running apps
to lose data.
More generally how does your app know that there isn't a really important
app running that desparately needs the memory you are now idly holding?
>
> >
> > > I am looking for suggestions or possible implementations of memory
> > > allocation which is guarrantied not to fail.
> >
> > No such thing. Since memory is a limited resource, some memory
> > allocations are bound to fail.
>
> Sure but it's unrealistic to think that because all memory is used right
now
> there won't be a few hundred bytes available in say 2 minutes from now.
>
No - In my experience that is exactly what happens because the memory is
consumed by a runaway app that will NEVER give it up.
> -- John
>
>