Bug report
Required Info:
- Operating System:
- Installation type:
- Version or commit hash:
- DDS implementation:
- Client library (if applicable):
Steps to reproduce issue
Define messages of fixed size
Array100kb.msg
Instantiate subscription to topic of this message type
#include <memory>
#include <iostream>
#include <thread>
#include <sstream>
#include "rclcpp/rclcpp.hpp"
#include "simple_memory_test/msg/array1kb.hpp"
class SimpleSubscriberNode : public rclcpp::Node {
public:
SimpleSubscriberNode(std::string name) : Node(name)
{
rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
_sub = this->create_subscription<simple_memory_test::msg::Array1kb>( "chatter",
std::bind(&SimpleSubscriberNode::simple_callback, this, std::placeholders::_1),
custom_qos_profile);
}
private:
void simple_callback(const simple_memory_test::msg::Array1kb::SharedPtr msg)
{
(void)msg;
}
rclcpp::Subscription<simple_memory_test::msg::Array1kb>::SharedPtr _sub;
};
int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
std::shared_ptr<SimpleSubscriberNode> sub_node = std::make_shared<SimpleSubscriberNode>("this_node");
rclcpp::spin(sub_node);
rclcpp::shutdown();
return 0;
}
Behavior
From what I have seen, the RAM required for instantiating a subscription, it's more or less invariant to the type of messages.
Note that I'm only running a system containing that subscriber node, no other nodes are alive.
However, testing this assumption for several values I got this

The physical memory required by the previously presented code, for a message between 50KB and 500KB it's bigger than the one required for a message of size more than 1MB.
After the peak of physical memory (56MB for a message of 450KB), the amount returns to the same constant value.
For what concerns the virtual memory usage, it keeps increasing a lot reaching 1.1GB for a message of size 4MB.
This behavior does not occur when creating publishers.
This behavior does not occur when using OpenSplice DDS.
Do you have any ideas why ?
May be related to this ? #203
Here you can find the package I used for running the tests.
https://github.com/alsora/ros2-code-examples/tree/master/simple_memory_test
It creates an executable for each data point.
I am measuring the RAM usage with
ps aux | grep sub_nodes
The package also contains a plot.py file where the exact results of the tests are hardcoded and you can get plot them again to better inspect the graph.
Bug report
Required Info:
Steps to reproduce issue
Define messages of fixed size
Array100kb.msg
Instantiate subscription to topic of this message type
Behavior
From what I have seen, the RAM required for instantiating a subscription, it's more or less invariant to the type of messages.
Note that I'm only running a system containing that subscriber node, no other nodes are alive.
However, testing this assumption for several values I got this
The physical memory required by the previously presented code, for a message between 50KB and 500KB it's bigger than the one required for a message of size more than 1MB.
After the peak of physical memory (56MB for a message of 450KB), the amount returns to the same constant value.
For what concerns the virtual memory usage, it keeps increasing a lot reaching 1.1GB for a message of size 4MB.
This behavior does not occur when creating publishers.
This behavior does not occur when using OpenSplice DDS.
Do you have any ideas why ?
May be related to this ? #203
Here you can find the package I used for running the tests.
https://github.com/alsora/ros2-code-examples/tree/master/simple_memory_test
It creates an executable for each data point.
I am measuring the RAM usage with
ps aux | grep sub_nodesThe package also contains a
plot.pyfile where the exact results of the tests are hardcoded and you can get plot them again to better inspect the graph.