Custom Container Allocators [ROS 1.1+]
Messages can now use an STL allocator of your choosing to do their container memory allocation.
Simple Use
If you have an allocator you'd like to use with the containers inside a message, the ROS_DECLARE_MESSAGE_WITH_ALLOCATOR macro will let you do it easily:
1 ROS_DECLARE_MESSAGE_WITH_ALLOCATOR(visualization_msgs::Marker, MyMarker, MyAllocator);
This declares MyMarker as a visualization_msgs::Marker that passes MyAllocator as a template argument to any container types (currently vector and string).
1 MyMarker marker;
Just like with an STL container, you can also pass an instance of an allocator to the messages' constructor, which will pass it along to the containers:






