1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

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.
This commit is contained in:
David Steele 2022-04-25 13:29:43 -04:00
parent c3b08f71ce
commit 5b5dbe0e7e

View File

@ -66,17 +66,24 @@ archivePushDrop(const String *walPath, const StringList *const processList)
uint64_t queueSize = 0;
bool result = false;
for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++)
MEM_CONTEXT_TEMP_RESET_BEGIN()
{
queueSize += storageInfoP(
storagePg(), strNewFmt("%s/%s", strZ(walPath), strZ(strLstGet(processList, processIdx)))).size;
if (queueSize > queueMax)
for (unsigned int processIdx = 0; processIdx < strLstSize(processList); processIdx++)
{
result = true;
break;
queueSize += storageInfoP(
storagePg(), strNewFmt("%s/%s", strZ(walPath), strZ(strLstGet(processList, processIdx)))).size;
if (queueSize > queueMax)
{
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);
}