ROS2 serious memory leak when using timer?
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:])