You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
5
5
## [Unreleased]
6
6
### Added
7
7
- More ESPMemoryMonitor examples: manual sampling without the background task and a panic-hook sketch that captures a final snapshot.
8
+
-`MemoryMonitorConfig::usePSRAMBuffers` to prefer PSRAM for monitor-owned long-lived containers via `ESPBufferManager` with automatic fallback to normal heap.
9
+
- Routed additional hot-path transient monitor scratch containers (threshold/task events, task-status capture, scope/tag threshold staging, and window analytics scratch vectors) through the same `ESPBufferManager` policy.
10
+
- Added internal/public model separation for history/scope/tag/task/leak state: monitor internals now use PSRAM-policy-aware storage models and convert to existing public API structs at return/callback boundaries.
8
11
### Fixed
9
12
- Mark the failed-allocation hook instance pointer as static so Arduino builds compile the callback correctly.
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ ESPMemoryMonitor is a tiny C++17 helper that wraps ESP-IDF heap/stack inspection
17
17
- Derived insights: windowed min/avg/max, slope-based bytes/second, and time-to-warn/critical estimates per region.
18
18
- Task visibility: stack state transitions (`Safe/Warn/Critical`), optional new/vanished task detection, and per-task thresholds.
19
19
- Export/panic helpers: convert snapshots to ArduinoJson for telemetry and install a shutdown/panic hook that captures a final snapshot before abort/restart.
20
+
- Optional PSRAM-backed monitor-owned buffers via `usePSRAMBuffers` (through `ESPBufferManager`) with automatic fallback to normal heap on non-PSRAM boards, including long-lived state, hot-path transient scratch containers, and internal storage models that are converted to public API structs at boundaries.
20
21
- Thread-safe with FreeRTOS mutexes; destructor tears down the sampler task and unregisters callbacks.
21
22
22
23
## Examples
@@ -44,6 +45,7 @@ void setup() {
44
45
cfg.maxScopesInHistory = 16;
45
46
cfg.windowStatsSize = 10;
46
47
cfg.enableTaskTracking = true;
48
+
cfg.usePSRAMBuffers = true; // optional: prefer PSRAM for monitor-owned containers
|`defaultTaskStackBytes` / `stackWarnFraction` / `stackCriticalFraction`|`4096` / `0.25` / `0.10`| Default stack headroom thresholds when per-task overrides are absent. |
165
167
|`leakNoiseBytes`|`1024`| Ignore free-byte changes smaller than this when flagging leak drift between checkpoints. |
168
+
|`usePSRAMBuffers`|`false`| Best-effort PSRAM preference for monitor-owned dynamic containers and internal storage models (history/scope/tag/task/leak internals plus transient threshold, scope/tag, window, and task-tracking scratch buffers); automatically falls back to normal heap when PSRAM is unavailable. |
166
169
167
170
`MemorySnapshot` holds `timestampUs` plus vectors of `RegionStats` (free bytes, low-water, largest block, fragmentation, slope/time estimates, window stats) and optional `TaskStackUsage` entries (task name, priority, state, free high-water bytes).
168
171
@@ -171,6 +174,7 @@ serializeJson(doc, Serial);
171
174
-`enableFailedAllocEvents` hooks IDF’s global failed-allocation callback; if you already use it elsewhere, coordinate registration to avoid conflicts.
172
175
- Threshold hysteresis is byte-based; bump `thresholdHysteresisBytes` if your allocator churns in small bursts.
173
176
- Fragmentation is `0` when free bytes are zero; values closer to `1.0` indicate more fragmentation.
177
+
-`usePSRAMBuffers` affects monitor-owned container allocations only; callback captures and other external allocations are not redirected.
174
178
175
179
## Restrictions
176
180
- ESP32 + FreeRTOS (Arduino-ESP32 or ESP-IDF) with C++17 enabled.
0 commit comments