Gets information about available memory.
void AvailMem(MemInfo *minfo, uint32 memflags);
This procedure returns information about the amount of memory that is currently available. You can get information about a particular kind of memory by setting the corresponding flags, such as MEMTYPE_VRAM or MEMTYPE_DRAM, in the flags argument. To get information about all memory that is available to the CPU, use MEMTYPE_ANY as the value of the flags argument.
The information about available memory is returned in a MemInfo structure:
Example 1: Memory Information Structure for
typedef struct MemInfo { uint32 minfo_SysFree; uint32 minfo_SysLargest; uint32 minfo_TaskFree; uint32 minfo_TaskLargest; } MemInfo;
The fields contain the following information:
Library routine implemented in clib.lib V20.
When you call AvailMem()
, you must request information about only one memory type. Attempting to find out about more than one memory type may produce unexpected results.
If you pass in a garbage minfo pointer, sparks may fly.
The information returned by AvailMem()
is inherently flawed, since you are existing in a multitasking environment. Memory can be allocated or freed asynchronous to the operation of the task calling AvailMem()
.