ros2 / demos

Apache License 2.0
491 stars 329 forks source link

[allocator_tutorial] Adding polymorphic allocators #650

Open AliAshkaniNia opened 11 months ago

AliAshkaniNia commented 11 months ago

I recently reviewed the Implementing a custom memory allocator section and wanted to provide a friendly suggestion. While the MyAllocator implementation works well for C++11, ROS 2 also supports C++17 polymorphic memory allocators which offer a simpler alternative. I believe adding examples using the polymorphic allocators could make this section more beginner-friendly.

I am prepared to provide a minimum working example and make the necessary modifications to the documentation. Please let me know if there are any particular reasons for not including this approach in the tutorial already, or if you think it would be valuable to add as an additional option.

clalancette commented 10 months ago

I'm not all familiar with the polymorphic allocators, but if they end up being a simpler alternative I think that would be welcome. If you'd like to submit a PR with that change, we are happy to take a look at it.