Ask Your Question
0

ROS2 serious memory leak when using timer?

asked 2019-04-11 02:39:21 -0500

ahlyder gravatar image

I have created almost the simplest ROS node possible in python with a single time doing nothing - code below. When I run it, memory consumption continuously increases and ultimately the my memory is used up. Is there something I am missing, or is this a known or unknown issue? Trying memory profiler (mprof) shows that in 4 min, memory consumption is increased by at least 10MB.

import sys
import rclpy
import time

from rclpy.node import Node

def main(args=None):
    rclpy.init(args=args)
node = Node('leak_test')

def timer_callback():
    time.sleep(0.005)
    #print("Timer Callback")

timer = node.create_timer(0.01, timer_callback)

try:
    rclpy.spin(node)
except KeyboardInterrupt:
    print("Shutdown initiated")

node.destroy_timer(timer)
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':
    main(sys.argv[1:])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-04-11 09:22:30 -0500

Dirk Thomas gravatar image
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

3 followers

Stats

Asked: 2019-04-11 02:39:21 -0500

Seen: 61 times

Last updated: Apr 11