gazebosim / gz-sim

Open source robotics simulator. The latest version of Gazebo.
https://gazebosim.org
Apache License 2.0
621 stars 251 forks source link

Unload model plugins when the model is removed from the world #113

Open diegoferigo opened 4 years ago

diegoferigo commented 4 years ago

As discussed in https://github.com/ignitionrobotics/ign-gazebo/issues/39#issuecomment-613957221, model plugins are not unloaded when the model is removed from the world.

There are few problems that this behaviour could cause:

  1. Memory leak. If the simulation is very long and models are inserted and deleted multiple times, the RAM consumption slowly increases. (e.g. https://github.com/ignitionrobotics/ign-gazebo/issues/47)
  2. If the plugin access ECM components of the model and it does not handle properly the case when they are not found (because the model has been removed), the behaviour could be undefined.

In #39 the problem was acknowledged but no specific issue was opened to track it.

ejalaa12 commented 1 year ago

Hi, I can confirm that this problem is still present in gazebo Garden. It's easily reproducable with an Hydrodynamics system which prints "No linear vel" once its model has been removed from the world. Which means the system is still running, but the entity is not present anymore.

Are there any update on this issue ? If, you can tell where I should look, I can create a PR with a fix.

takahashi-e6 commented 1 week ago

Hi.

This problem seems to occur in Fortress as well, and can be reproduced by simply deleting the plugin-enabled model with the following command:

ign service -s /world/empty/remove --reqtype ignition.msgs.Entity --reptype ignition.msgs.Boolean --timeout 5000 --req 'type: MODEL; name: "my_model"'

How can I properly delete a model?

I looked up the ign command but couldn't find the answer.