Obtain a memory usage snapshot for the current platform.
On Pico, RAM capacity and free space come from linker and C allocator state. Heap usage is a high-water mark and freeing memory does not reduce it. Flash free space excludes the image's final partially occupied erase sector and any flash block region reserved by hw_block_flash_init().
Calculate percentages only when the corresponding total is nonzero:
double ram_free_percent = 100.0 * usage.ram_free_bytes /
usage.ram_total_bytes;
double stack_free_percent = 100.0 * usage.stack_free_bytes /
usage.stack_total_bytes;
double flash_free_percent = 100.0 * usage.flash_free_bytes /
usage.flash_total_bytes;
ram_free_percent describes primary SRAM available for heap growth. Stack capacity is separate scratch SRAM and has its own percentage.
- Parameters
-
| usage | Output snapshot. Must not be NULL. |
- Returns
- true on success, false when
usage is NULL.