Configure Zero Copy Loaned Messages
See the Loaned Messages article for details on how loaned messages work.
How to disable Loaned Messages
Publishers
By default, Loaned Messages will try to borrow the memory from underlying middleware if it supports Loaned Messages.
The ROS_DISABLE_LOANED_MESSAGES
environment variable can be used to disable Loaned Messages, and fallback to normal publisher behavior, without any code changes or middleware configuration.
You can set the environment variable with the following command:
export ROS_DISABLE_LOANED_MESSAGES=1
To maintain this setting between shell sessions, you can add the command to your shell startup script:
echo "export ROS_DISABLE_LOANED_MESSAGES=1" >> ~/.bashrc
export ROS_DISABLE_LOANED_MESSAGES=1
To maintain this setting between shell sessions, you can add the command to your shell startup script:
echo "export ROS_DISABLE_LOANED_MESSAGES=1" >> ~/.bash_profile
set ROS_DISABLE_LOANED_MESSAGES=1
If you want to make this permanent between shell sessions, also run:
setx ROS_DISABLE_LOANED_MESSAGES 1
Subscriptions
Currently using Loaned Messages is not safe on subscription, see more details in this issue.
Because of this, by default Loaned Messages is disabled
on subscription with Set disable loan to on by default even though underlying middleware supports that.
To enable Loaned Messages on subscription, you need to set the environment variable ROS_DISABLE_LOANED_MESSAGES
to 0
explicitly.
export ROS_DISABLE_LOANED_MESSAGES=0
To maintain this setting between shell sessions, you can add the command to your shell startup script:
echo "export ROS_DISABLE_LOANED_MESSAGES=0" >> ~/.bashrc
export ROS_DISABLE_LOANED_MESSAGES=0
To maintain this setting between shell sessions, you can add the command to your shell startup script:
echo "export ROS_DISABLE_LOANED_MESSAGES=0" >> ~/.bash_profile
set ROS_DISABLE_LOANED_MESSAGES=0
If you want to make this permanent between shell sessions, also run:
setx ROS_DISABLE_LOANED_MESSAGES 0