ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Ros eats up RAM while recording rosbag remotely

asked 2018-01-11 16:14:26 -0500

mhariharasudan gravatar image

I am running my ros application on a robot (arm) with limited RAM (1 GB).

I configured my robot as the rosmaster. The rosbag recording was happening on my local linux machine whoser Ros master was the robot.

Whenever I start my rosbag record, I can see that the available RAM space on my arm board shoots down eventually causing a bad alloc error.

I do not understand why invoking a subscriber (rosbag) on my local computer would consume RAM on the robot. Any thoughts or pointers would be much appreciated.

This is a cross compiled ros kinetic version on QNX running within a realtime loop. The data to be sent over to the ros are written to a lock free ring buffer from which ros publisher running on a separate thread reads and publishes.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2018-01-12 00:17:35 -0500

ahendrix gravatar image

The ROS publisher has an outbound queue. If messages are published more quickly than they can be transferred over the network, the outbound queue will fill up until it starts dropping messages.

You can compute the rough amount of ram that the queue will use by multiplying the average message size by the queue size.

Note the publisher queues are per-subscriber, so if you have multiple subscribers you should budget for each subscriber separately.

edit flag offensive delete link more

Comments

Wouldnt this queue size be fixed at compile time. If so, why would the RAM usage slowly spike up causing memory crash. This seems to be either memory leak or dynamic allocation. Also, the RAM usage starts only when the rosbag record is run on the client machine.

mhariharasudan gravatar image mhariharasudan  ( 2018-01-12 09:42:22 -0500 )edit

Wouldnt this queue size be fixed at compile time.

no, it's configured upon publisher creation.

This seems to be either memory leak or dynamic allocation

it's dynamic allocation.

RAM usage starts only when the rosbag record is run on the client machine.

yes. That's when queueing starts.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 09:44:09 -0500 )edit

Does this mean that the messages published by the publishers are actually "published" only when there is a subscriber for them. I am more interested in understanding why the RAM usage dynamically increases at runtime and is not fixed at compile time.

mhariharasudan gravatar image mhariharasudan  ( 2018-01-12 09:46:03 -0500 )edit

Even if it is dynamically allocated, they should be pre-allocated when the publishers are created and not when the execution starts?

mhariharasudan gravatar image mhariharasudan  ( 2018-01-12 09:47:54 -0500 )edit

No. ROS does not do any pre-allocation of buffers.

ahendrix gravatar image ahendrix  ( 2018-01-12 12:58:23 -0500 )edit

Since the number of subscribers is not known at compile time and buffers are per-subscriber, there's no way to know how many buffers to pre-allocate. Since the message size is not always known, there isn't enough information to know the buffer size to pre-allocate.

ahendrix gravatar image ahendrix  ( 2018-01-12 13:00:34 -0500 )edit

If you want control over this type of feature, perhaps you should look at ROS2, which is based on DDS.

ahendrix gravatar image ahendrix  ( 2018-01-12 13:01:36 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2018-01-11 16:14:26 -0500

Seen: 1,059 times

Last updated: Jan 12 '18