From eff1b1bb44de6bca3b138f50ff725378fd7ce76b Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Wed, 10 May 2023 16:44:20 -0400 Subject: [PATCH] BP5: fixes memory error with IBM XL (cherry picked from commit 501278282a04712b490eccc7519e23f71f20a3a7) --- source/adios2/engine/bp5/BP5Writer.cpp | 18 +++++++++++++++--- .../adios2/toolkit/format/bp5/BP5Serializer.h | 4 ---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Writer.cpp b/source/adios2/engine/bp5/BP5Writer.cpp index 7c5af59723..6888573ca2 100644 --- a/source/adios2/engine/bp5/BP5Writer.cpp +++ b/source/adios2/engine/bp5/BP5Writer.cpp @@ -547,12 +547,14 @@ void BP5Writer::EndStep() m_Profiler.Start("AWD"); // TSInfo destructor would delete the DataBuffer so we need to save it // for async IO and let the writer free it up when not needed anymore - adios2::format::BufferV *databuf = TSInfo.DataBuffer; - TSInfo.DataBuffer = NULL; m_AsyncWriteLock.lock(); m_flagRush = false; m_AsyncWriteLock.unlock(); - WriteData(databuf); + + // WriteData will free TSInfo.DataBuffer + WriteData(TSInfo.DataBuffer); + TSInfo.DataBuffer = NULL; + m_Profiler.Stop("AWD"); /* @@ -688,6 +690,16 @@ void BP5Writer::EndStep() m_EndStepEnd = Now(); /* Seconds ts2 = Now() - m_EngineStart; std::cout << "END STEP ended at: " << ts2.count() << std::endl;*/ + + if (TSInfo.AttributeEncodeBuffer) + { + delete TSInfo.AttributeEncodeBuffer; + } + + if (TSInfo.MetaEncodeBuffer) + { + delete TSInfo.MetaEncodeBuffer; + } } // PRIVATE diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.h b/source/adios2/toolkit/format/bp5/BP5Serializer.h index 5ceeb54dad..71ec480e88 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.h +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.h @@ -42,10 +42,6 @@ class BP5Serializer : virtual public BP5Base ~TimestepInfo() { - delete MetaEncodeBuffer; - if (AttributeEncodeBuffer) - delete AttributeEncodeBuffer; - delete DataBuffer; } };