View Issue Details

IDProjectCategoryView StatusLast Update
0001809ardourbugspublic2020-04-19 20:12
Reporterjohne53 Assigned Topaul  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Summary0001809: [PATCH] Memory leak (may still be present in current version)
DescriptionWhen a property gets added to an XML Node using XMLNode::add_property(),
a new XML property gets created at line 321 of xml++.cc - i.e.

XMLProperty *tmp = new XMLProperty(ns, v);

When the node gets deleted, it seems as if any memory allocated to
properties also gets deleted (although I haven't traced through the code to
find out how this happens). However, a property's memory only gets deleted as long as the property wasn't removed. If I remove the property using XMLNode::remove_property() its memory never seems to get deleted.

I just wondered if XMLNode::remove_property() should be deleting any memory that was originally allocated by XMLNode::add_property() ?
Additional InformationI first reported this about 3 weeks ago via the Dev mailing list. I'm only reporting it again because I'm not sure if it got actioned.
TagsNo tags attached.

Activities

johne53

2008-06-14 17:29

reporter   ~0005023

Paul - I implemented some code to fix this back in February and everything's worked fine since then. Would you like to have my changes?

paul

2008-06-16 01:55

administrator   ~0005026

Yes please.

cth103

2009-10-20 09:25

administrator   ~0006762

Do you have those changes, John?

cth103

2009-10-20 18:51

administrator   ~0006777

Committed a fix to delete the XMLProperty in remove_property for A3 in revision 5824. Patch attached against 2.0. It's not particularly important as remove_property is only used in one place in Ardour, as far as I can see.

Thanks for the report!

2009-10-20 18:52

 

1809.patch (379 bytes)   
diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc
index 942727a..cf78ca5 100644
--- a/libs/pbd/xml++.cc
+++ b/libs/pbd/xml++.cc
@@ -340,7 +340,9 @@ void
 XMLNode::remove_property(const string & n)
 {
 	if (_propmap.find(n) != _propmap.end()) {
-		_proplist.remove(_propmap[n]);
+		XMLProperty* p = _propmap[n];
+		_proplist.remove (p);
+		delete p;
 		_propmap.erase(n);
 	}
 }
1809.patch (379 bytes)   

paul

2009-10-30 17:22

administrator   ~0006997

committed to 2.X

system

2020-04-19 20:12

developer   ~0021546

Issue has been closed automatically, by Trigger Close Plugin.
Feel free to re-open with additional information if you think the issue is not resolved.

Issue History

Date Modified Username Field Change
2007-08-04 07:23 johne53 New Issue
2008-06-14 17:29 johne53 Note Added: 0005023
2008-06-16 01:55 paul Note Added: 0005026
2009-10-20 09:25 cth103 Note Added: 0006762
2009-10-20 09:25 cth103 Status new => feedback
2009-10-20 18:51 cth103 Note Added: 0006777
2009-10-20 18:52 cth103 File Added: 1809.patch
2009-10-20 18:52 cth103 Status feedback => assigned
2009-10-20 18:52 cth103 Assigned To => paul
2009-10-20 18:52 cth103 cost => 0.00
2009-10-20 18:52 cth103 Summary Memory leak (may still be present in current version) => [PATCH] Memory leak (may still be present in current version)
2009-10-30 17:22 paul Note Added: 0006997
2009-10-30 17:22 paul Status assigned => resolved
2009-10-30 17:22 paul Resolution open => fixed
2020-04-19 20:12 system Note Added: 0021546
2020-04-19 20:12 system Status resolved => closed