cycle effect now tracks the heap leakage of the running effects. Cause somewhere's a memory leak leading to restarts of the ESP every about 2 days...

This commit is contained in:
Fabian Schlenz 2019-10-04 12:03:03 +02:00
parent 97dd6de280
commit 2b7033b685
2 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@ private:
Effect* effect = NULL;
uint16_t effect_id = -1;
unsigned long effectSince = 0;
uint16_t _heap_free = 0;
uint8_t _effects_count;
public:
CycleEffect();

View File

@ -29,16 +29,26 @@ void CycleEffect::changeEffect() {
if (effect) delete effect;
int16_t diff;
uint16_t old_heap = _heap_free;
_heap_free = ESP.getFreeHeap();
if (old_heap) {
// diff positive = More heap used (baad)
// diff negative = Less heap used (good-ish)
diff = old_heap - _heap_free;
LOGln("CycleEffect * Heap usage: #%d,%d,%+d", effect_id, _heap_free, diff);
}
delay(25);
LOGln("CycleEffect * Searching for new effect #%d", new_id);
uint8_t count = 0;
for (uint8_t i=0; i<effects_size; i++) {
if (effects[i].use_in_cycle) {
if (new_id == 0) {
if (count == new_id) {
effect = effects[i].create();
break;
} else {
new_id--;
}
count++;
}
}
if (effect) {