I've identified a memory leak issue in ROS 2 Humble running on Jetson Orin NX. When components repeatedly allocate memory without proper cleanup, the system shows continuous memory growth.
Reproduction Steps:
# Create a simple node that continuously allocates memory
def __init__(self):
super().__init__('leaky_component')
self._stored_data = []
self.timer = self.create_timer(1.0, self.timer_callback)
def timer_callback(self):
# Allocate memory without cleanup
new_data = np.random.rand(1000, 1000)
self._stored_data.append(new_data)
Observed Behavior:
Memory usage increases linearly No memory recovery between allocations System becomes unstable over time
System Details:
ROS 2 Humble NVIDIA Jetson Orin NX JetPack 6.1
Has anyone else encountered this issue? What's the best practice for handling memory cleanup in ROS 2 components?