Memory Optimizations
This commit is contained in:
@@ -96,6 +96,11 @@ void DirectoryNode::buildDirectoryTree(const char *currentPath)
|
||||
mp3Files.clear();
|
||||
ids.clear();
|
||||
|
||||
// Reserve memory to reduce heap fragmentation (optimization 3)
|
||||
subdirectories.reserve(8); // Reserve space for 8 subdirectories
|
||||
mp3Files.reserve(16); // Reserve space for 16 MP3 files
|
||||
ids.reserve(16); // Reserve space for 16 IDs
|
||||
|
||||
File rootDir = SD.open(currentPath);
|
||||
while (true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user