1111#include < ESPMemoryMonitor.h>
1212#include < esp_log.h>
1313
14- static ESPMemoryMonitor monitor;
14+ ESPMemoryMonitor monitor;
1515static MemoryTag httpTag;
1616static MemoryTag otaTag;
1717
@@ -35,33 +35,33 @@ void setup() {
3535 monitor.setTagBudget (httpTag, {60 * 1024 , 80 * 1024 });
3636 monitor.setTagBudget (otaTag, {40 * 1024 , 64 * 1024 });
3737
38- monitor.onScope ([](const ScopeStats & s) {
38+ monitor.onScope ([](const ScopeStats& s) {
3939 ESP_LOGI (" SCOPE" , " %s used %+d DRAM %+d PSRAM in %llu us" ,
4040 s.name .c_str (),
4141 static_cast <int >(s.deltaInternalBytes ),
4242 static_cast <int >(s.deltaPsramBytes ),
4343 static_cast <unsigned long long >(s.durationUs ));
4444 });
4545
46- monitor.onTagThreshold ([](const TagThresholdEvent & evt) {
46+ monitor.onTagThreshold ([](const TagThresholdEvent& evt) {
4747 ESP_LOGW (" TAG" , " %s now %s at %u bytes" ,
4848 evt.usage .name .c_str (),
49- evt.usage .state == ThresholdState::Critical ? " CRITICAL" :
50- evt. usage . state == ThresholdState::Warn ? " WARN " : " OK" ,
49+ evt.usage .state == ThresholdState::Critical ? " CRITICAL" : evt. usage . state == ThresholdState::Warn ? " WARN "
50+ : " OK" ,
5151 static_cast <unsigned >(evt.usage .totalInternalBytes + evt.usage .totalPsramBytes ));
5252 });
5353
54- monitor.onLeakCheck ([](const LeakCheckResult & res) {
55- for (const auto & d : res.deltas ) {
56- const char * regionName = d.region == MemoryRegion::Psram ? " PSRAM" : " DRAM" ;
54+ monitor.onLeakCheck ([](const LeakCheckResult& res) {
55+ for (const auto & d : res.deltas ) {
56+ const char * regionName = d.region == MemoryRegion::Psram ? " PSRAM" : " DRAM" ;
5757 ESP_LOGI (" LEAK" , " %s drift %+0.1fB frag %+0.2f" , regionName, d.deltaFreeBytes , d.deltaFragmentation );
5858 }
5959 if (res.leakSuspected ) {
6060 ESP_LOGW (" LEAK" , " possible leak between %s -> %s" , res.fromLabel .c_str (), res.toLabel .c_str ());
6161 }
6262 });
6363
64- monitor.onTaskStackThreshold ([](const TaskStackEvent & evt) {
64+ monitor.onTaskStackThreshold ([](const TaskStackEvent& evt) {
6565 if (evt.appeared ) {
6666 ESP_LOGI (" TASK" , " task created: %s" , evt.usage .name .c_str ());
6767 return ;
@@ -72,8 +72,8 @@ void setup() {
7272 }
7373 ESP_LOGW (" TASK" , " %s stack %s (%uB headroom)" ,
7474 evt.usage .name .c_str (),
75- evt.state == StackState::Critical ? " CRITICAL" :
76- evt. state == StackState::Warn ? " WARN " : " SAFE" ,
75+ evt.state == StackState::Critical ? " CRITICAL" : evt. state == StackState::Warn ? " WARN "
76+ : " SAFE" ,
7777 static_cast <unsigned >(evt.usage .freeHighWaterBytes ));
7878 });
7979}
0 commit comments