ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

delete TransformListener object in python to release computational resource

asked 2016-11-02 12:31:59 -0600

Mike Gao gravatar image

updated 2016-11-02 12:32:38 -0600

Hello! Recently I notice that, after I create a TransformListener object in a class in python, e.g.: = TransformListener(),

the created tf object gets stuck in the memory, even I try deleting it in the "__del__(self)" method of the class with:

del = None,

it does not work. The TransformListener object is used by a method of this class. The problem is that when I continue to create the object of this class (which is called by another class during operation), the TransformListener objects accumulate and occupy the computational resources. Thus my question is that how I can get rid of it to free the unnecessarily occupied resources? I appreciate any answers and suggestions in advance!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-11-02 13:30:26 -0600

tfoote gravatar image

There may be something not cleaning up properly, but python does not necessarily clean up when del is called.

Here are some more resources if you want to dig in deeper:

edit flag offensive delete link more

answered 2023-06-05 04:26:30 -0600

pajaz gravatar image

Here's what worked for me:


I deleted the subscriber of tf2_ros.TransformListener:

self.tf_buffer = tf2_ros.Buffer()
self.tf_listener = tf2_ros.TransformListener(self.tf_buffer, self)

then delete with:

edit flag offensive delete link more

Question Tools



Asked: 2016-11-02 12:31:59 -0600

Seen: 265 times

Last updated: Nov 02 '16