Function to calculate the memory available for malloc
Dependents: AvailableMemory_HelloWorld MCBBThermostat helloaabbc SP14P1_skeleton
segundo::Utilities Namespace Reference
A collection of utilities. More...
Functions | |
int | AvailableMemory (int resolution=256, int maximum=0x8000, bool disableInterrupts=true) |
Return the memory available for a malloc call. |
Detailed Description
A collection of utilities.
Function Documentation
int AvailableMemory | ( | int | resolution = 256 , |
int | maximum = 0x8000 , |
||
bool | disableInterrupts = true |
||
) |
Return the memory available for a malloc call.
This is done by a binary search approach calling malloc/free starting with a maximum.
Example:
#include <stdio.h> #include "AvailableMemory.h" int main() { printf("Available memory (bytes to nearest 256) : %d\n", AvailableMemory()); printf("Available memory (exact bytes) : %d\n", AvailableMemory(1)); }
- Parameters:
-
resolution Resolution in number of bytes, 1 will return the exact value, default will return the available memory to the nearest 256 bytes maximum Maximum amount of memory to check, default is 32K (0x8000) disableInterrupts Disable interrupts whilst checking, default is true
- Returns:
- Available memory in bytes accurate to within resolution
Definition at line 7 of file AvailableMemory.cpp.
Generated on Thu Jul 14 2022 23:46:08 by 1.7.2