From 4d8951df1e24440a01141950e8c4a030cbdd5f54 Mon Sep 17 00:00:00 2001 From: Chris Birkhold Date: Wed, 5 Jun 2024 23:52:31 -0700 Subject: [PATCH] Release XML element when property node was bound (analog to GetNode() ... This significantly reduces memory cost by not keeping a large number of XML elements around in the common case of successfully binding the property in the constructor. --- src/math/FGPropertyValue.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/math/FGPropertyValue.cpp b/src/math/FGPropertyValue.cpp index 7e60c33789..cef989f510 100644 --- a/src/math/FGPropertyValue.cpp +++ b/src/math/FGPropertyValue.cpp @@ -49,8 +49,12 @@ FGPropertyValue::FGPropertyValue(const std::string& propName, Sign = -1.0; } - if (PropertyManager->HasNode(PropertyName)) + if (PropertyManager->HasNode(PropertyName)) { PropertyNode = PropertyManager->GetNode(PropertyName); + + assert(PropertyNode); + XML_def = nullptr; // Now that the property is bound, we no longer need that. + } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%