Skip to content
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 on demand unloading #34

Merged
merged 4 commits into from
Apr 9, 2016

Conversation

rhaschke
Copy link

@rhaschke rhaschke commented Apr 3, 2016

On-demand-unloading was broken because:

  • loading always needs to be done, otherwise the classes from the lib cannot be known
  • MultiLibraryClassLoader shouldn't unload its libs when on-demand-unloading is enabled

This relates to ros/pluginlib#37 and fixes ros/pluginlib#38.

@rhaschke
Copy link
Author

rhaschke commented Apr 3, 2016

Hm. Didn't run the test before. Will have a short look.

@rhaschke
Copy link
Author

rhaschke commented Apr 3, 2016

Ah, obviously my changes need to be applied to MultiLibraryClassLoader, not the base ClassLoader.
I will fix that and rebase.

@rhaschke rhaschke force-pushed the fix-on-demand-unloading branch from 051cfd5 to f32686f Compare April 3, 2016 15:23
@rhaschke
Copy link
Author

rhaschke commented Apr 3, 2016

IMHO the class_loader library has a fundamental design flaw: The unloading of libraries is tight to the existance of a ClassLoader. However, for example in liburdf, the loader could be destroyed before its created plugin objects. I don't see a reason, why this shouldn't be possible conceptually.

Of course, it's hard(er) to implement: Knowledge about a loaded library (load_ref_count, plugin_ref_count) should be stored separate from the ClassLoader. Actually this is already the case for some info (MetaObjectVector + LibraryVector), but not yet the mentioned variables. The plugin deleter (onPluginDeletion) should accordingly check against those global variables instead of ClassLoaders.

Additionally I suggest to keep the library loaded while a ClassLoader is instantiated. Otherwise the library might get loaded and unloaded for every single object instance (if this gets destroyed in between).

Furthermore, all the static global variables should be integrated in a singleton shared_ptr class, such that destruction order can be controlled. Having this singleton a shared_ptr, also allows to deal with static ClassLoader instances (as in liburdf): Only if all ClassLoader instances are destroyed, the actual singleton pointer should be released. This will finally solve #33.

As you see, I have some implementation ideas in mind. However, I don't have time to work on this in the near future. The current PR fixes on-demand-loading for MultiLibClassLoader, but still requires the class loaders to be kept instantiated as long as as plugin objects exist.

rhaschke added a commit to ubi-agni/robot_model that referenced this pull request Apr 7, 2016
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
@mikaelarguedas
Copy link
Member

Hi Robert,
Sorry to keep you waiting.

This seems like a reasonable incremental improvement. I totally agree with you that there is room for improvement on the way ClassLoader and loaded classes are tied together.
As you stated this would require some work and I don't know if anybody will have time to address this in the near future.

Thanks for your work!

@mikaelarguedas mikaelarguedas merged commit 8a80797 into ros:indigo-devel Apr 9, 2016
@mikaelarguedas
Copy link
Member

@dirk-thomas any comment about this fix ?

@dirk-thomas
Copy link
Member

LGTM

@rhaschke rhaschke deleted the fix-on-demand-unloading branch July 6, 2016 06:45
guihomework pushed a commit to ubi-agni/robot_model that referenced this pull request Aug 25, 2016
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/robot_model that referenced this pull request Sep 13, 2016
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Dec 19, 2017
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Aug 10, 2018
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Feb 8, 2019
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Oct 7, 2020
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Sep 21, 2022
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
rhaschke added a commit to ubi-agni/urdf that referenced this pull request Sep 22, 2022
- crashes on exit: ros/class_loader#33
- on-demand-unloading works with ros/class_loader#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants