improve robustness when heap is low

* customMappingTable: allocate using calloc instead of new (new will throw exception if nor enough heap)
* fixing a few minor memory leaks
* ws.cpp: catch out-of-memory in sendLiveLedsWs
* ws.cpp: change interval to 80ms (120 ws very slow...)
This commit is contained in:
Frank
2023-05-15 21:15:24 +02:00
parent 9f6278ae8a
commit 6d23eb6874
6 changed files with 49 additions and 16 deletions

View File

@@ -37,7 +37,8 @@
void WS2812FX::setUpMatrix() {
#ifndef WLED_DISABLE_2D
// erase old ledmap, just in case.
if (customMappingTable != nullptr) delete[] customMappingTable;
//if (customMappingTable != nullptr) delete[] customMappingTable;
if (customMappingTable != nullptr) free(customMappingTable);
customMappingTable = nullptr;
customMappingSize = 0;
@@ -68,7 +69,9 @@ void WS2812FX::setUpMatrix() {
return;
}
customMappingTable = new uint16_t[Segment::maxWidth * Segment::maxHeight];
//customMappingTable = new uint16_t[Segment::maxWidth * Segment::maxHeight];
if (nullptr != customMappingTable) free(customMappingTable);
customMappingTable = (uint16_t *) calloc(Segment::maxWidth * Segment::maxHeight, sizeof(uint16_t));
if (customMappingTable != nullptr) {
customMappingSize = Segment::maxWidth * Segment::maxHeight;