Commit 63c22698 authored by Chuck Atkins's avatar Chuck Atkins

ADIOS: Fix memory leaks by adding deletes

Change-Id: I73107bebe60d9b1351b1a0a5818b65b1668f3a81
parent ad47d6ab
......@@ -141,6 +141,8 @@ Reader::Reader()
//----------------------------------------------------------------------------
Reader::~Reader()
{
this->Close();
delete this->Impl;
delete this->Ctx;
}
......@@ -208,6 +210,16 @@ void Reader::Open(const std::string &fileName)
}
}
//----------------------------------------------------------------------------
void Reader::Close()
{
if(this->Impl->File)
{
adios_read_close(this->Impl->File);
this->Impl->File = NULL;
}
}
//----------------------------------------------------------------------------
void Reader::GetStepRange(int &tStart, int &tEnd) const
{
......@@ -227,6 +239,8 @@ void Reader::ScheduleReadArray(int id, void *data, int step, int block)
int err = adios_schedule_read_byid(this->Impl->File, sel, id,
step, 1, data);
ReadError::TestEq(0, err);
adios_selection_delete(sel);
}
//----------------------------------------------------------------------------
......
......@@ -44,6 +44,10 @@ public:
// Open the ADIOS file and cache the variable names and scalar data
void Open(const std::string &fileName);
// Description:
// Close an already open file handle and free it's resources
void Close();
// Description:
// Retrieve the total number of seps
void GetStepRange(int &tStart, int &tEnd) const;
......
......@@ -228,6 +228,23 @@ Writer::Writer(ADIOS::TransportMethod transport,
//----------------------------------------------------------------------------
Writer::~Writer()
{
std::map<std::string, const WriterImpl::ScalarInfo*>::const_iterator s;
for(s = this->Impl->ScalarRegistry.begin();
s != this->Impl->ScalarRegistry.end();
++s)
{
delete s->second;
}
std::map<std::string, const WriterImpl::ArrayInfo*>::const_iterator a;
for(a = this->Impl->ArrayRegistry.begin();
a != this->Impl->ArrayRegistry.end();
++a)
{
delete a->second;
}
adios_free_group(this->Impl->Group);
delete this->Impl;
delete this->Ctx;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment