Memavail and Maxavail
The old Turbo Pascalfunctions MemAvail and MaxAvail functions are no longer available in Free Pascalas of version 2.0. The reason for this incompatibility is below:
On modern operating systems, 9 the idea of "Available Free Memory" is not valid for an application. The reasons are:
One processor cycle after an application asked the OS how much memory is free, another application may have allocated everything.
It is not clear what "free memory" means: does it include swap memory, does it include disk cache memory (the disk cache can grow and shrink on modern OS’es), does it include memory allocated to other applications but which can be swapped out, etc.
Therefore, programs using MemAvail and MaxAvail functions should be rewritten so they no longer use these functions, because it does not make sense anymore on modern OS’es. There are 3 possibilities:
Use exceptions to catch out-of-memory errors.
Set the global variable "ReturnNilIfGrowHeapFails" to
Trueand check after each allocation whether the pointer is different fromNil.Don’t care and declare a dummy function called
MaxAvailwhich always returnsHigh(LongInt)(or some other constant).
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
