delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/19/05:30:13

Date: Sat, 19 Aug 2000 12:30:51 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: r_maj AT poczta DOT onet DOT pl
Message-Id: <2593-Sat19Aug2000123050+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.2.emacs20_6 I) and Blat ver 1.8.5b
CC: djgpp AT delorie DOT com
In-reply-to: <8nkfqq$hhj$1@info.cyf-kr.edu.pl> (r_maj@poczta.onet.pl)
Subject: Re: RE : get free memory info doesn't work !
References: <8njgsi$5ps$1 AT info DOT cyf-kr DOT edu DOT pl> <4634-Fri18Aug2000203600+0300-eliz AT is DOT elta DOT co DOT il> <8nkfqq$hhj$1 AT info DOT cyf-kr DOT edu DOT pl>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Rafal Maj" <r_maj AT poczta DOT onet DOT pl>
> Newsgroups: comp.os.msdos.djgpp
> Date: Sat, 19 Aug 2000 00:57:38 +0200
> 
> But... still I don't know how to check this amount of free memory.
> I used sbrk(),  _go32_dpmi_get_free_memory_information(...),
> _go32_remaining_virtual_memory(), value returning by malloc - all things
> described in DJGPP FAQ,
> and *NONE* of them worked,
> excaly - all of them returned the sam value before and after delete[]...

This is expected, the FAQ says that you cannot in general know what is
the amount of free memory available to a program.

> So, finaly I think, that ther isn't ANY method for checking REAL ammount of
> free virtual / physical memory under DJGPP ?

That's true.  It isn't DJGPP's fault, though: most environments
supported by DJGPP are multi-program operating systems such as
Windows, where the amount of available virtual memory depends on what
oter programs running on the machine do at any given moment.  For
example, malloc might return NULL, but if you close some of the other
windows and try again, it might succeed.

The other part of the puzzle, the size of the free memory pool
maintained by malloc/free, can be tracked by changing the sources of
these functions (which are freely available in djlsr203.zip archive).

However, if all you need is to prevent program from crashing when it
runs out of free memory, you need to check malloc/realloc results for
NULL, or (in C++) define a suitable exception handler for failures in
the operator new.  Then you will not need to worry about how much
memory is left.

- Raw text -


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