Ask Your Question

Maximum samples and unbounded type length in ROS2 DDS entity

asked 2018-08-01 11:33:32 -0500

aks gravatar image

updated 2018-08-01 11:34:04 -0500

This is an extension to this question.

I ran a ROS2 demo_py taker and observed the RTI admin console to know more about the data types and QoS.

As you can see in the attached image, it has only one member of type String but the max size of the string here is : 2147483647 bytes which looks a bit strange to me. Also, if you look at the Max Samples, they are also quite big.

Questions :

  1. Is this the normal memory allocation of a data type ?
  2. How are the maximum samples calculated ? Are these based on the size of the datatype ? RTI_AdminConsole

ps : i know it is not ok to post a picture but i think it gives a much clearer view of the problem.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-01 12:32:51 -0500

marguedas gravatar image

RTI is using RTI_INT32_MAX as the maximal size for string when support for unbounded string is enabled. As mentioned in answer from the memory is allocated for 0 elements by default and then reallocated as messages come in. So if you look at your memory usage it should not allocate 2GB of RAM to store the string. Similarly, if you look at the packets sent on wireshark or similar tool you will see that only the characters present in the string will be serialized and sent.

The max sample size is provided by the <TYPE>_Plugin_get_serialized_sample_max_size_ex Connext generated function. In this case it always returns: RTI_CDR_MAX_SERIALIZED_SIZE.

You can find the connext generated code in your build folder under <PACKAGE_NAME>/rosidl_typesupport_connext_cpp

For the std_msgs/String message it will be the files: rosidl_typesupport_connext_cpp/std_msgs/msg/dds_connext/String_Plugin.cxx rosidl_typesupport_connext_cpp/std_msgs/msg/dds_connext/String_.cxx

edit flag offensive delete link more


@marguedas : thanks for the explanation.But I still dont get why it allocates such a huge memory for a string ?

aks gravatar image aks  ( 2018-08-01 13:00:56 -0500 )edit

It does not allocate that memory for a string.

RTI's definition of an unbounded string is a string that can be "up to" RTI_INT32_MAX characters. But the allocated memory is relative to the size of the string that is sent

marguedas gravatar image marguedas  ( 2018-08-01 13:37:26 -0500 )edit

Then what is this memory for and from where is it coming ? I have no clue

aks gravatar image aks  ( 2018-08-01 13:38:52 -0500 )edit

Can you please provide an example of 2GB of memory being allocated?

marguedas gravatar image marguedas  ( 2018-08-01 13:40:40 -0500 )edit

To interface ROS2 and native RTI Connext, the type should be similar, since ROS2 gives me a 2GB string, I need to have the same on the RTI native side as well which creates a problem. That is why in first place my quesion, where does this size come from ? @marguedas

aks gravatar image aks  ( 2018-08-01 13:43:36 -0500 )edit

then maybe I understood wrong, what does 2147483647 represent here ? Isnt it the size of the string ?

aks gravatar image aks  ( 2018-08-01 13:45:06 -0500 )edit 2147483647 is the max size of int32 and this is what it represents since RTI interprets unbounded string as max value of Int32 ? Am I right ?

aks gravatar image aks  ( 2018-08-01 13:55:50 -0500 )edit

Yes. RTI interprets an unbounded sting as a string that can have a size between 0 and RTI_INT32_MAX (2147483647)

marguedas gravatar image marguedas  ( 2018-08-01 13:58:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-08-01 11:33:32 -0500

Seen: 334 times

Last updated: Aug 01 '18