Mail Archives: djgpp/2000/08/19/05:30:13
> 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 -