0
$\begingroup$

I have developed a substantial ROS2 Planner node containing various navigation algorithms, with some components written in Python and others in C++. Pybind11 is used to call C++ algorithms from the Python code. Monitoring the system’s memory usage, the node starts at 98MB before any tests are run. When executing tests such as the A_star algorithm or linear_path_tracker, the memory usage increases every 2 to 4 minutes by increments of 0.2MB to 4MB, and this increased memory is not being released.

I need to identify the parts of the code responsible for this memory increase and retention.

Investigations Conducted:

  • A simple ROS2 node in Python (printing "hello world") consumes approximately 10 to 20MB.
  • Importing third-party libraries into the ROS2 node accounts for approximately 80MB of memory usage.
  • Due to memory constraints on my target board, I need to reduce the memory usage from these imported libraries and identify the code responsible for the memory increase.

Solutions Attempted:

  • Valgrind: Valgrind reports no memory leaks in the program, providing a clean report with no errors. The summary of the Valgrind report shows only Python libraries, without any code lines from my files, even after a thorough review of the full report. valgrind memory chunk here valgrind report summary here

  • Memory_Profiler: This tool shows constant memory usage of 34MB, while the system monitor indicates the node's memory usage at approximately 80MB and increasing over time.

memory profiler report plot here

So Now if someone has any suggestion/solution/tool by which I can see a detailed memory snapshot (tells chunk of code which is using memory) of my node so please let me know. please keep in mind that the code base is so big more than 5000 lines of code and was not written by me so I could not go through each line and try to find where we are assigning memory not also we have both Python and C++ algorithms and Pybind11 for binding.

Request for Assistance: I am seeking suggestions, solutions, or tools that can provide a detailed memory snapshot, identifying specific chunks of code responsible for memory usage in my node. The codebase exceeds 5000 lines and includes both Python and C++ algorithms with Pybind11 bindings, making it impractical to manually inspect each line for memory assignments. Any insights or recommendations would be greatly appreciated.

Thank you in advance for your help.

Environment:

  • ROS2 Version: Humble
  • OS: Ubuntu 22.04.4 LTS
  • Python: 3.10
New contributor
Mujadid Ali is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.