Open andrewacashner opened 2 years ago
If you add a delete statement in the document destructor does it fix it?
https://github.com/rism-digital/libmei/blob/develop/src/meidocument.cpp#L56
Something like delete this->root
?
I think I found the solution. The problem is with the destructor for MeiElement. Instead of calling attributes.clear()
I looped through the vector and delete each element, as you already do in ~MeiDocument()
. (I don't know why it's not necessary to do the same for the children
vector.) I changed the destructor to the following and I was able to compile the sample program above with no complaints from clang
:
In src/meielement.cpp
at line 32:
mei::MeiElement::~MeiElement() {
vector<MeiAttribute*>::iterator attr;
for(attr = attributes.begin(); attr != attributes.end(); ++attr) {
delete *attr;
}
}
I am seeing a memory leak with the simplest example document:
test.cpp
:I compile with this command:
This is the output from
clang
about the memory leak: