Commit 50127828 authored by Bolea Sanchez, Vicente Adolfo's avatar Bolea Sanchez, Vicente Adolfo
Browse files

BP5: fixes memory error with IBM XL

parent 8ce4ff9b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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");

    /*
+14 −6
Original line number Diff line number Diff line
@@ -1333,19 +1333,27 @@ BP5Serializer::TimestepInfo BP5Serializer::CloseTimestep(int timestep,
    MBase->BitField = tmp;
    NewAttribute = false;

    struct TimestepInfo Ret
    {
        Formats, Metadata, AttrData, CurDataBuffer
    };
    struct TimestepInfo Ret;
    Ret.NewMetaMetaBlocks = Formats;
    Ret.MetaEncodeBuffer.reset(Metadata);
    Ret.AttributeEncodeBuffer.reset(AttrData);
    Ret.DataBuffer = CurDataBuffer;
    CurDataBuffer = NULL;

    if (Info.AttributeFields)
    {
        free_FMfield_list(Info.AttributeFields);
        Info.AttributeFields = NULL;
    }
    Info.AttributeFieldCount = 0;

    if (Info.AttributeData)
    {
        free(Info.AttributeData);
        Info.AttributeData = NULL;
    }
    Info.AttributeSize = 0;

    return Ret;
}

+3 −11
Original line number Diff line number Diff line
@@ -36,17 +36,9 @@ public:
    struct TimestepInfo
    {
        std::vector<MetaMetaInfoBlock> NewMetaMetaBlocks;
        Buffer *MetaEncodeBuffer;
        Buffer *AttributeEncodeBuffer;
        std::shared_ptr<Buffer> MetaEncodeBuffer;
        std::shared_ptr<Buffer> AttributeEncodeBuffer;
        BufferV* DataBuffer;

        ~TimestepInfo()
        {
            delete MetaEncodeBuffer;
            if (AttributeEncodeBuffer)
                delete AttributeEncodeBuffer;
            delete DataBuffer;
        }
    };

    typedef struct _MetadataInfo