When removing models from the world using ODE, the collision space for these models lingers, causing the simulation to become quadratically slower over time.
The collision space for a model is tracked by
ODEPhysics::dataPtr::spaces, which is populated in
ODEPhysics::CreateLink() (https://bitbucket.org/osrf/gazebo/src/47c6f792045ae8e67f3aa3ba64c07006151f470c/gazebo/physics/ode/ODEPhysics.cc?at=default&fileviewer=file-view-default#ODEPhysics.cc-494). However, no code is present anywhere to remove this space once a model is no longer active. This causes the quadratic performance degredation as further detailed in this question on Gazebo Answers.
It appears to me the solution is to introduce an
ODEModel class to manage the collision space. This is exactly what I have done in the attached patch file, which appears to make the slowdown go away.