Skip to content

Commit

Permalink
Fix memory leak when there are Joined Arrays in streaming mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Jul 3, 2023
1 parent 1b99c8c commit 6917bf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ void BP5Deserializer::InstallMetaData(void *MetadataBlock, size_t BlockLen,
m_JoinedDimenOffsetArrays = new std::vector<void *>();
m_JoinedDimenOffsetArrays->resize(writerCohortSize);
JoinedDimArray[Step] = m_JoinedDimenOffsetArrays;
m_FreeableMBA = nullptr;
m_FreeableJDOA = nullptr;
}
}
else
Expand All @@ -726,7 +726,7 @@ void BP5Deserializer::InstallMetaData(void *MetadataBlock, size_t BlockLen,
if (!m_JoinedDimenOffsetArrays)
{
m_JoinedDimenOffsetArrays = new std::vector<void *>();
m_FreeableMBA = m_JoinedDimenOffsetArrays;
m_FreeableJDOA = m_JoinedDimenOffsetArrays;
}
if (writerCohortSize > m_JoinedDimenOffsetArrays->size())
{
Expand Down Expand Up @@ -2003,7 +2003,13 @@ BP5Deserializer::~BP5Deserializer()
delete VarRec.second;
}
if (m_FreeableMBA)
{
delete m_FreeableMBA;
}
if (m_FreeableJDOA)
{
delete m_FreeableJDOA;
}
for (auto &step : MetadataBaseArray)
{
delete step;
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class BP5Deserializer : virtual public BP5Base
std::vector<void *> *m_FreeableMBA = nullptr;

std::vector<void *> *m_JoinedDimenOffsetArrays = nullptr;
std::vector<void *> *m_FreeableJDOA = nullptr;

// for random access mode, for each timestep, for each writerrank, what
// metameta info applies to the metadata
Expand Down

0 comments on commit 6917bf9

Please sign in to comment.