delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/06/07/15:38:04

Subject: Re: malloc() doesn't return a null pointer when out of memory
From: Marco Imperatore <mimperat AT cs DOT dal DOT ca>
To: dj AT ctron DOT com (DJ Delorie)
Date: Sun, 7 Jun 1992 16:36:07 -0300
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> > I can certainly see how malloc() could not easily detect that the
> > swap disk is full but it should be able to easily see if there is not
> > enough virtual memory to satisfy the request.
> 
> Swap space IS your virtual memory.  In order to detect that malloc()
> should return NULL, you have to figure out how much swap space you
> would need if you suddenly referenced ALL the memory in the program,
> and see if the disk currently has enough space to handle that request.
> It's not a trivial piece of code to keep track or and/or compute that
> information.
> 
> If it's that much of an issue for you, MAKE THE CHANGES YOURSELF!
> That's why I send out source code - if you don't like it, change it.
> 
> DJ
> dj AT ctron DOT com
> Life is a banana.

DJ:

You seem to take offense at many of the comments people make regarding
your port of gcc (as shown by your last comment to my post).  Although
your reactions are understandable, they are rarely called for 
as there often is no insult intended.  I'm sure that everyone reading these
messages is aware that your port of gcc is better than no port at all.
I also don't think that many people expect YOU to make the changes
suggested here.  I'm sorry to say that in any group of individuals
there are always those who see things differently than you do.  I'm
sorry because this often causes conflicts.  However, it is also the
case that it is only with differences of opinions that things can
change for the better.

As far as the swap space and virtual memory issues go, my comments
are based on my own limited experience at writing operating systems,
the little time I've spent thinking about, investigating, and writing a
multitasking OS for 386s, and from several years of unix experience.
All these lead me to believe that there is an elegant and easy way
to have malloc() return NULL when there is no more virtual memory
and/or swap space.  This does not imply that I wish to make changes
to gcc to reflect my experience as I have no time to do so... but
I do think that I can offer some helpful insight to others on this list.
Hopefully they have not been insulted by them as much as you have.

Regards.

-marco-


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019