wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Utility/GetMemFree

Version 6 (modified by Don Wilson, 13 years ago) ( diff )

--

GetMemFree

Get the amount of free RAM memory available

int GetMemFree(void);

Parameters

Function does not accept any parameters.

Return Value

This function returns the number of unused K bytes of RAM in the system. This is the total free memory available. A request for a smaller amount of memory could still fail if there is not a large enough contiguous block of memory available.

Remarks

The function reads /proc/meminfo to obtain the result. It can be useful when testing an application to use the function to display free memory periodically and run the application for several hours/days to make sure the application is not allocating memory and never releasing it.

Examples

string str = StrFmt("Free memory %d K bytes", GetMemFree());
DisplayText(0, 0, str);
// If less than 5M RAM free display a message
if(GetMemFree() < 5000)
{
   SetCurColor(COLOR_ATTENTION);
   DisplayText(0, 0, "Memory Low");
}

See Also

Note: See TracWiki for help on using the wiki.