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

Which memory is used while publishing messages in ROS ?

asked 2018-04-17 02:38:28 -0600

aks gravatar image

When messages are published i.e. fed into a queue, where are these messages stored ? Does it use the physical memory on the disc ? Is there also some memory sharing i.e. is the memory space split between Master, publishers and subscribers ? If yes, then where are the messages stored ? in Master's memory ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-04-17 03:01:05 -0600

gvdhoorn gravatar image

When messages are published i.e. fed into a queue, where are these messages stored ?

For a typical PC: in RAM.

Does it use the physical memory on the disc ?

No (unless you consider a situation where your OS decides to swap out pages of your virtual memory to disk for some reason and those pages happen to be where some messages are stored).

Is there also some memory sharing i.e. is the memory space split between Master, publishers and subscribers ?

No. Not by default.

And definitely not between the master and publishers/subscribers.

Between pub-sub pairs: maybe, depends on the transport you have configured.

If yes, then where are the messages stored ? in Master's memory ?

Never.

The master is never involved in message exchange, it really only functions as a lookup service.

edit flag offensive delete link more

Comments

ok...but lets stay i am feeding messages in a buffer while publishing then does it means these messages are stored in the memory of Publisher and once these topics are subscribed, the memory space of the publisher is free and the subscriber memory is occupied ? @gvdhoorn

aks gravatar image aks  ( 2018-04-17 03:04:52 -0600 )edit

At a certain level: yes, that is what happens.

But to be precise: if a publisher is publishing with no-one subscribed, those msgs are lost. That is how pub-sub works (or at least, in ROS 1).

gvdhoorn gravatar image gvdhoorn  ( 2018-04-17 03:06:50 -0600 )edit

@☻gvdhoorn As you mentioned : if a subscriber is subscribing to a topic and then intentionally breaks connection, the subscriber is still publishing (e.g. talker-listener example). Where does these messages go ? must be stored in some memory. Should the Master tell the Publisher to stop publishing

aks gravatar image aks  ( 2018-04-20 09:32:30 -0600 )edit

Msg exchange (at some level) is just two processes transmitting bytes to each other over a TCP/IP (or UDP) connection. All the same rules apply as with other TCP/IP connections, so: if a subscribers drops the connection, the publisher is (virtually) immediately aware. The code will then ..

gvdhoorn gravatar image gvdhoorn  ( 2018-04-20 10:00:13 -0600 )edit

.. remove the subscription from its internal lists and no msgs will be sent to that connection any more.

must be stored in some memory

well yes. As I already wrote: everything is stored in RAM. It must be, as there is nothing else in a computer.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-20 10:01:39 -0600 )edit

@gvdhoorn No message will be sent to that particular subscriber but the publisher will continue to publish messages even if no one is subscribing to it ? Is it correct ?

aks gravatar image aks  ( 2018-04-23 02:07:11 -0600 )edit

Whether or not there are subscribers does not influence the publisher in any way (conceptually). If the only action we consider is the Publisher::publish(..) call, then the publisher can continue to use that without any subscribers present/known.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-23 02:09:41 -0600 )edit

but then isnt this a waste of memory ?

aks gravatar image aks  ( 2018-04-23 02:22:29 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-04-17 02:38:28 -0600

Seen: 1,101 times

Last updated: Apr 17 '18