Repository navigation
UnitDefinition::areIdentical no longer leaks its temporary copies (#503) - #504
Conversation
The copies of the two unit definitions were allocated on the heap and deleted at the end of the function, but the early return for overall multipliers which differ skipped the deletes, so every such call leaked both copies (about 11 kB). The copies are on the stack now and released on every return. Fixes sbmlteam#503.
fbergmann
left a comment
There was a problem hiding this comment.
@matthiaskoenig thank you so much for the PR, this solves the issue.
the test failures are unrelated to this issue, I'll leave this PR open, so I can add the necessary commits and merge at the end of the week with those issues solved.
Do you need a new release right away?
|
It would be great to have a release as soon as possible (but this is not blocking anything at the moment). You and Sarah fixed a ton of issues in the last week for which I have a lot of work around code in my code base (e.g. I have a own I would really like to get rid of all the unnecessary code and checks on my side, because things have been fixed upstream in libsbml. Best |
|
@matthiaskoenig I'll make it a priority and aim for a release Wed, Thursday at the latest. @skeating that would be fine with you, right? |
Fixes #503.
UnitDefinition::areIdenticalcopies both unit definitions to simplify and reorder them, on the heap, and deletes the copies at the end. The earlyreturn identical;for overall multipliers which differ skipped the deletes, so every call which compares unit definitions with different multipliers leaked both copies with their units (about 11 kB per call). As suggested in the issue, the copies are allocated on the stack now, so every return releases them; the logic is unchanged.Check (a C++ reproduction of the issue, linked against the shared library built from
developmentand from this branch, undervalgrind --leak-check=full, 100 iterations ofareIdentical(mass, rate)with different multipliers andareIdentical(rate, rate2)with equal overall multipliers):developmentareEquivalentandareIdenticalSIUnitsalready delete their copies on every return.