Is there any known action, bad implementation, classical error, you name it… causing a memory leak in a Python Tango device?
I’m obviously not looking for a way to generate a leak I’m just wondering if there’s something that could easily explain the memory leak we observe in one of our python devices. The latter is a simple frontend (or facade) which main task is to map and forward attributes of an other device.
So far, we forward the attributes “by hand” forwarding the value read on the underlying device. For instance:
read_forwarded(self, attr):
da = self.my_dev_proxy.read_attribute(attr.get_name())
attr.set_value(da.value)
A few memory leaks have been fixed last year, for instance:
If you manage to reproduce it with a simple device, I can run it against the latest version of pytango to check if it has already been fixed. Also, I see you’re not using the pytango high-level API. Any reason why? Here’s what your code would look like with the new API:
I am not sure this is your case, but there is a known memory leak in Tango C++ (not PyTango) if by any chance, you happen to call set_value() more than once in a read request. Something like:
read_forwarded(self, attr):
da = self.my_dev_proxy.read_attribute(attr.get_name())
attr.set_value(da.value)
attr.set_value(da.value)
At the time I discussed with Manu Taurel and we decided it could be considered as bad programming and not necessarily a memory leak.
Not entirely true. Using the new API doesn’t prevent you from doing something like:
from tango.server import attribute
class D(...)
def init_device(self):
...
voltage = attribute(name='Volt', fget=self.read_v)
self.add_attribute(voltage)
def read_v(self, attr):
attr.set_value(12345)
@attribute
def current(self):
return 4321
It is true that you mix new-style with old-style :-P. I will create an issue in github to be able to handle this case.