AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
A namespace providing encapsulation for functions that report the available memory in SRAM. More...
Functions | |
size_t | freeSRAM () |
Get the total free memory remaining in SRAM. More... | |
size_t | freeMemoryBetweenHeapAndStack () |
Get the free memory between the heap and the stack. More... | |
void | resetHeap () |
Reset the heap to an empty (virgin) state. More... | |
size_t | memoryAvailableOnFreeList () |
Get the free memory on the heap free-list. More... | |
size_t | getFreeListStats (int *nbrBlocks, size_t *sizeSmallestBlock, size_t *sizeLargestBlock) |
Get information about the heap free-list. More... | |
A namespace providing encapsulation for functions that report the available memory in SRAM.
size_t MemUtils::freeMemoryBetweenHeapAndStack | ( | ) |
Get the free memory between the heap and the stack.
This does not include any memory potentially available within the heap on the free-list. It executes quickly, so this function is useful for checking to make sure the heap and stack aren't in danger of collision.
size_t MemUtils::freeSRAM | ( | ) |
Get the total free memory remaining in SRAM.
This includes memory on the free-list (if the heap is used) as well as memory available between the heap and the stack (which grow towards each other). If the heap has been used, the function will walk the free-list to determine the total amount of free memory.
size_t MemUtils::getFreeListStats | ( | int * | nbrBlocks, |
size_t * | sizeSmallestBlock, | ||
size_t * | sizeLargestBlock | ||
) |
Get information about the heap free-list.
This provides information about the number of blocks on the free list, the size of the largest and smallest block, as well as the total memory held on the free list.
nbrBlocks
returns the number of blocks in the free-list. sizeSmallestBlock
returns the size of the smallest block on the free-list. answerGeneralCall
returns the size of the largest block on the free-list.size_t MemUtils::memoryAvailableOnFreeList | ( | ) |
Get the free memory on the heap free-list.
This shows the total free memory available on the free-list. This is the sum of the free-blocks contained within the heap.
void MemUtils::resetHeap | ( | ) |
Reset the heap to an empty (virgin) state.
This function resets the heap to an empty, pristine state. Not only are all memory allocations abandoned, but the free list is also purged, leaving everything between the start of the heap and the top of the stack as unallocated (actually, never-allocated) memory.