Closed heroxxCN closed 5 years ago
I've solve it. The "read" function is defined like this: def read(self, tags=None, group=None, size=None, pause=0, source='hybrid', update=-1, timeout=5000, sync=False, include_error=False, rebuild=False):
Call "read" function like this: _opc.read(tags=yourtag,group='GPRN‘)
I have a project reading the same items every 5 seconds. I use the "read" function to read items,the project exits after running about 3 hours . Then I use tracemalloc to find the problem: Sun, 17 Feb 2019 16:22:31 opcRead.py[line:53] INFO 2 memory blocks: 100.0 KiB Sun, 17 Feb 2019 16:22:31 opcRead.py[line:55] INFO File "C:\Python36\lib\site-packages\OpenOPC.py", line 321 Sun, 17 Feb 2019 16:22:31 opcRead.py[line:55] INFO self._group_handles_tag[sub_group][n] = tag ...... Sun, 17 Feb 2019 16:22:41 opcRead.py[line:53] INFO 2 memory blocks: 120.0 KiB Sun, 17 Feb 2019 16:22:41 opcRead.py[line:55] INFO File "C:\Python36\lib\site-packages\OpenOPC.py", line 321 Sun, 17 Feb 2019 16:22:41 opcRead.py[line:55] INFO self._group_handles_tag[sub_group][n] = tag ...... Sun, 17 Feb 2019 16:22:53 opcRead.py[line:53] INFO 2 memory blocks: 200.0 KiB Sun, 17 Feb 2019 16:22:53 opcRead.py[line:55] INFO File "C:\Python36\lib\site-packages\OpenOPC.py", line 321 Sun, 17 Feb 2019 16:22:53 opcRead.py[line:55] INFO self._group_handles_tag[sub_group][n] = tag ...... Sun, 17 Feb 2019 19:22:09 opcRead.py[line:53] INFO 2 memory blocks: 30720.0 KiB Sun, 17 Feb 2019 19:22:09 opcRead.py[line:55] INFO File "C:\Python36\lib\site-packages\OpenOPC.py", line 321 Sun, 17 Feb 2019 19:22:09 opcRead.py[line:55] INFO self._group_handles_tag[sub_group][n] = tag
As you see,the memory usage get bigger and bigger. I read the source code of file openopc.py and found it add tags to _group_handles_tag every time I read items. Here is my question: How to read items with group?