MemoryUsage
MemoryUsage copied to clipboard
Pj/easier to test
This is for a backwards-compatible enhancement to the MemoryUsage library.
At this time MemoryUsage is basically a set of macros to collect usage information as text through Serial.print().
I would like to have more direct access to the numerical values. This gives me more flexibility in using the values. With these changes:
- Duplicate code (such as
(__brkval == 0 ? (int)&__heap_start : (int)__brkval)
to get heap end forMEMORY_PRINT_HEAPEND
andMEMORY_PRINT_HEAPSIZE
) is gathered into single (inline) functions. This helps ensure all code using that value will calculate it the same way. - A sketch can print values in decimal or hex (or both)
- A sketch can customize the output text
- A sketch can send output to somewhere other than Serial
- A sketch can do more than just print the information collected. For example a sketch could safely restart itself if it detected a memory leak.
This pull request includes https://github.com/Locoduino/MemoryUsage/pull/4 , so if you want both PRs, you only need to review/approve this one.