diff --git a/src/gausskernel/storage/access/transam/multixact.cpp b/src/gausskernel/storage/access/transam/multixact.cpp index fccc7cf85..f29f2eb24 100644 --- a/src/gausskernel/storage/access/transam/multixact.cpp +++ b/src/gausskernel/storage/access/transam/multixact.cpp @@ -1278,13 +1278,10 @@ static const char *MXStatusToString(MultiXactStatus status) static char *mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members) { - static char *str = NULL; + char *str = NULL; StringInfoData buf; int i; - if (str != NULL) - pfree(str); - initStringInfo(&buf); appendStringInfo(&buf, XID_FMT " %d[" XID_FMT " (%s)", multi, nmembers, @@ -1295,7 +1292,7 @@ static char *mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *me } appendStringInfoChar(&buf, ']'); - str = MemoryContextStrdup(TopMemoryContext, buf.data); + str = MemoryContextStrdup(SESS_GET_MEM_CXT_GROUP(MEMORY_CONTEXT_STORAGE), buf.data); pfree(buf.data); return str; }