Fix memory leaks in archivePushDrop().
A string was leaked for every file processed.
Since the list can be quite large it also makes sense to reset the context occasionally.
@@ -66,6 +66,8 @@ archivePushDrop(const String *walPath, const StringList *const processList)
uint64_t queueSize = 0;
bool result = false;
+ MEM_CONTEXT_TEMP_RESET_BEGIN()
+ {
for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++)
{
queueSize += storageInfoP(
@@ -76,7 +78,12 @@ archivePushDrop(const String *walPath, const StringList *const processList)
result = true;
break;
}
+
+ // Reset the memory context occasionally so we don't use too much memory or slow down processing
+ MEM_CONTEXT_TEMP_RESET(1000);
+ }
}
+ MEM_CONTEXT_TEMP_END();
FUNCTION_LOG_RETURN(BOOL, result);
}
