AvailMem

Gets information about available memory.

Synopsis

void AvailMem(MemInfo *minfo, uint32 memflags);

Description

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:

minfo_SysFree
The amount of memory of the specified memory type in the system-wide free memory pool, in bytes. The pool contains only full pages of memory.
minfo_SysLargest
The size, in bytes, of the largest series of contiguous pages of the specified memory type in the system-wide free memory pool.
minfo_TaskFree
The amount of memory of the specified type in the task's free memory pool, in bytes.
minfo_TaskLargest
The size, in bytes, of the largest contiguous block of the specified memory type that can be allocated from the task's free memory pool.

Arguments

minfo
A pointer to the MemInfo structure used to return the result.
memflags
Flags that specify the type of memory to get information about. These flags can include MEMTYPE_ANY, MEMTYPE_VRAM, MEMTYPE_DRAM, MEMTYPE_BANKSELECT, MEMTYPE_BANK1, MEMTYPE_BANK2, MEMTYPE_DMA, MEMTYPE_CEL, MEMTYPE_AUDIO, and MEMTYPE_DSP. For information about these flags, see the description of AllocMem().

Implementation

Library routine implemented in clib.lib V20.

Associated Files

mem.h
ANSI C Prototype
clib.lib
ARM Link Library

Caveats

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().

See Also

AllocMem(), free(), FreeMem(), malloc()