-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release XML element when property value node was bound #1096
Release XML element when property value node was bound #1096
Conversation
… ... 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1096 +/- ##
=======================================
Coverage 24.91% 24.91%
=======================================
Files 168 168
Lines 18108 18110 +2
=======================================
+ Hits 4511 4513 +2
Misses 13597 13597 ☔ View full report in Codecov by Sentry. |
Did you take any memory measurements to compare? Out of interest I tried a couple of tests to see how much of a memory difference there is. I used Visual Studio 2022 and took a look at some memory figures with and without this change. I ran the Before: After: |
In my test case I'm seeing a 25% reduction in runtime memory cost. Your example is a bit less then that but still a nice win for essentially a one liner that simply removes unused memory. While the absolute value appears small, in memory constraint environments every little helps. This also removes clutter when memory debugging in other areas. |
Out of interest, are you using JSBSim in some memory constrained environment? |
Yes. I'm approaching 256 kb runtime load. This change has the highest memory saving over lines changed ratio but if there is interest I can extract a few more that are still transparent. |
Out of interest what environment are you running JSBSim in? |
Good catch @cbirkhold ! BTW the assertion you've added makes me think that there are most likely some places in the code where the value returned by |
@bcoconni The assert I added almost as an explanation to why the follow line is 'legal'. The
I think the code is generally pretty good on that in either setting the |
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.