Skip to content

Commit

Permalink
Merge pull request ornladios#3684 from eisenhauer/FixLeak
Browse files Browse the repository at this point in the history
Fix memory leak when there are Joined Arrays in streaming mode
  • Loading branch information
eisenhauer authored Jul 3, 2023
2 parents 1b99c8c + 6917bf9 commit 68b282c
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 68b282c

Please sign in to comment.