-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix trajectory info memory leak #93
Conversation
Signed-off-by: John Shepherd <john@openrobotics.org>
Codecov Report
Continue to review full report at Codecov.
|
Marking this as |
Sounds good, I'm going to test Dome in a bit to see if the memory leak occurs there too, I noticed there was some significant changes of the Actor code so I wanted to confirm that the leak still occurs for Dome. |
Looks like Dome has this memory leak as well and this fix will fix it. It also appears Dome doesn't have the extra memory leak that Citadel has 🤔 |
Could we make this a smart pointer in This also currently violates rule-of-five principle. |
Dome will use |
Thanks for the fix!
Dome switched from doing manual interpolation of skeletal bone poses (by ign-common) to interpolation done by the rendering engine. So one place I see that may leak is here: There are also a few other possible places for leaks which I don't a matching yikes, quite a few leaks in our animation code |
Signed-off-by: John Shepherd <john@openrobotics.org>
Signed-off-by: John Shepherd <john@openrobotics.org> Signed-off-by: Michael Carroll <michael@openrobotics.org>
Simple fix but took awhile to find and I think deserves some explanation as well as some tools I used that can be used in the future for memory profiling (possibly this part deserves its own tutorial or guide).
It was discovered that there was a significant memory leak in any ign-gazebo examples involving actors. I used a project called mem-usage-ui which was very simple yet effective in being able to visually confirm the existence of memory leaks. The output from the actor example that was experiencing serious leakage is as follows:
It can be seen that the memory leakage grew by about 100Mb in just one minute, if left for 15-20 minutes, this could crash the computer. Using heaptrack or
valgrind
didn't quite prove effective given it monitors the ruby executable, outputting little to no helpful information. For this reason, I'd recommend we get a standalone custom gui example out, similar to custom_server as this would allowvalgrind
to do its job. I did, however, find that memleax was quite useful in pinpointing memory leaks, the output is a bit complicated to discern and there are false positives, but it proved very helpful in pointing me right to the culprit function that was leaking (in this case, ActorMeshAnimationAt(...)).After further investigation, I found that line 894 of SceneManager.cc
auto trajs = this->dataPtr->actorTrajectories[_id];
was the problem line that was spawning newTrajectoryInfo
's, invoking this constructor for every currently existingTrajectoryInfo
in thethis->dataPtr->actorTrajectories[_id]
vector, I suppose when assigning that vector to a new variable, the (deep) copy operation is made and that vector is duplicated, resulting in the original vector remaining as the value of thatthis->dataPtr->actorTrajectories
map and a new copy vector set totrajs
.So adding a simple deletion of
this->dataPtr
to the destructor ofTrajectoryInfo
fixed up the memory leak, which can be visually confirmed in the following graphSo, not perfect, there appears to be another smaller leak somewhere, but ~10Mb / minute is much better than the original. I'll continue to look for the remaining leaks.
Signed-off-by: John Shepherd john@openrobotics.org