Skip to content

Possible memory leak in spin_some() #1638

@BriceRenaudeau

Description

@BriceRenaudeau

Bug report

When using rclcpp::spin_some(node);, the node resources increase forever.

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • binaries
  • Version or commit hash:
    • Rolling
  • DDS implementation:
    • Fast-RTPS or CycloneDDS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Compile and execute this simple node.

#include <rclcpp/rclcpp.hpp>
int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  auto node = std::make_shared<rclcpp::Node>("foo");
  while(rclcpp::ok())
  {
    rclcpp::spin_some(node);
  }

  rclcpp::shutdown();
  return 0;
}

Using htop you will see the resources of the process increase.

Expected behavior

The node resources should be stable.

Actual behavior

The node resources increase until the OS kills the node because of memory storage.
Out of memory: Killed process

Additional information

It can be easily bypassed by creating an executor out of the loop and spinning it inside.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions