How to generate a memory leak in a Python device? [SOLVED]
|
|
---|---|
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: Is there anything wrong in this approach?
|
|
|
---|---|
Hi Nicolas, A few memory leaks have been fixed last year, for instance: https://github.com/tango-cs/pytango/commit/e54198afc1ad2daa981da4a05ab82d6ed551d69e https://sourceforge.net/p/tango-cs/bugs/758/ https://sourceforge.net/p/tango-cs/bugs/701/ 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:
Cheers |
|
|
---|---|
Hi Vincent, Thanks for your help. A few memory leaks have been fixed last yearWe're still using PyTango-8.1.2 and I suspect we are facing the bug #758. So, the first thing to do is to switch to the latest version. Edit: according to our download page, the current PyTango version is 8.0.2 It seems I have to dive into the github repo. I see you're not using the pytango high-level API. Any reason why? Most attributes of our Frontend device are dynamic. The new API decorators can't be used in this case. |
|
|
---|---|
|
Hi Nicolas, 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:
At the time I discussed with Manu Taurel and we decided it could be considered as bad programming and not necessarily a memory leak. Most attributes of our Frontend device are dynamic. The new API decorators can't be used in this case.Not entirely true. Using the new API doesn't prevent you from doing something like:
It is true that you mix new-style with old-style . I will create an issue in github to be able to handle this case. Thanks for reporting Cheers |
|
|
---|---|
Thanks Tiago. I rechecked the code. No double call to 'set_value'. I'm compiling pyTango 9… |
|
|
---|---|
Good news guys. Switching to PyTango 9.2.2 solves the problem. No more leak! Thanks. BTW, are forwarded attributes available in PyTango 9.2.2? |