Skip to content

Commit 2d87bb0

Browse files
okhsunrogAnthonyGrondinMabezDevplayfulFence
authored
Add heap usage stats with defmt (#2619)
* feat(esp-alloc): Add heap usage stats and provide `esp_alloc::get_info!()` macro * refactor(esp-alloc): Feature gate internal memory usage that requires extra computation. - Introduce the `internal-heap-stats` feature for `esp-alloc`. - Add `esp_alloc::get_info!()` to `psram_quad` example to show usage and ensure coverage of the feature in tests. * refactor(esp-alloc): Remove `get_info!()` macro in favour of documenting `HEAP.stats()` * Implement defmt::Format for HeapStats and RegionStats * rustfmt * show usage percent + move bar drawing logic to separate functions * update doc comments * Fixed a typo in qa-test/src/bin/psram_quad.rs Co-authored-by: Scott Mabin <[email protected]> * minor improvements to write bar functions * Aligned the indentation in Cargo.toml Co-authored-by: Kirill Mikhailov <[email protected]> * Fixed a typo in docs Co-authored-by: Kirill Mikhailov <[email protected]> * Nitpicking x2 Co-authored-by: Kirill Mikhailov <[email protected]> * Surround a function call with backticks Co-authored-by: Kirill Mikhailov <[email protected]> * rustfmt --------- Co-authored-by: Anthony Grondin <[email protected]> Co-authored-by: Scott Mabin <[email protected]> Co-authored-by: Kirill Mikhailov <[email protected]>
1 parent b6117d5 commit 2d87bb0

File tree

4 files changed

+308
-4
lines changed

4 files changed

+308
-4
lines changed

esp-alloc/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- `esp_alloc::HEAP.stats()` can now be used to get heap usage informations (#2137)
13+
1214
### Changed
1315

1416
### Fixed

esp-alloc/Cargo.toml

+14
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,24 @@ default-target = "riscv32imc-unknown-none-elf"
2323
features = ["nightly"]
2424

2525
[dependencies]
26+
defmt = { version = "0.3.8", optional = true }
27+
cfg-if = "1.0.0"
2628
critical-section = "1.1.3"
2729
enumset = "1.1.5"
2830
linked_list_allocator = { version = "0.10.5", default-features = false, features = ["const_mut_refs"] }
31+
document-features = "0.2.10"
2932

3033
[features]
3134
default = []
3235
nightly = []
36+
37+
## Implement `defmt::Format` on certain types.
38+
defmt = ["dep:defmt"]
39+
40+
## Enable this feature if you want to keep stats about the internal heap usage such as:
41+
## - Max memory usage since initialization of the heap
42+
## - Total allocated memory since initialization of the heap
43+
## - Total freed memory since initialization of the heap
44+
##
45+
## ⚠️ Note: Enabling this feature will require extra computation every time alloc/dealloc is called.
46+
internal-heap-stats = []

0 commit comments

Comments
 (0)