Memory leakage
Brought to you by:
barry_b
It seems to have memory leakage with OpenOPC.
For example, the following code consume about 100ko at each iteration :
import OpenOPC
while True:
client.connect('CODESYS.OPC.DA')
res = client.read(client.list("PLC2.Application.GVL.*"))
client.close()
(Question also asked on StackOverflow : http://stackoverflow.com/questions/19137947/why-my-app-leaks-memory-how-to-avoid-memory-leakage)
A workaround for the memory leak in your example is to call read() using
the "group" argument. Also, be sure to stay connected to the OPC server
and don't disconnect/reconnect each time through the loop. Example...
import OpenOPC
client.connect('CODESYS.OPC.DA')
tags = client.list("PLC2.Application.GVL.*")
while True:
res = client.read(tags, group='MyGroup')
client.close()
On Sun, Oct 6, 2013 at 9:28 AM, Difool difool80@users.sf.net wrote:
Related
Bugs: #9
It solves the problem.
Thank you very much, Barry
hi, i tried reading using group, the memory leak stops, but that data is not updating at all !, it just gets the data of the first read, and with the old time stamp too..
any suggestions ?
With some OPC servers you may have to set an explicit update rate when
using a read group. Example...
opc.read(tags, group='MyGroup', update=1)
where the update rate is specified in seconds.
On Mon, Dec 23, 2013 at 11:21 AM, Mohannad Shaheen mohsh86@users.sf.netwrote:
Related
Bugs: #9
Well, group and update parameters seem to solve the problem when reading.
But I can see that memory leaks also when calling write().
Right now I'm "solving" this by restarting OpenOPC service but I'm quite unhappy with this.
Last edit: jk987 2015-10-21
Just an idea without any further investigation:
Maybe the group creation during each tags writing consumes memory?
I was doing something similar in Delphi and I got experience that in the background I create one group used for writing. And always when I want to write tag value I add tag to this group, write value, and remove tag from this group. But this group still exists prepared for the next writitng of any item.
Almost exactly a year later somebody (vista3) asked me how I solved this problem.
For couple weeks or months I was restarting OpenOPC service from Scheduled tasks in Windows.
(Calling some "net start ..." and "net stop ..." commands which could be possible also from Python.)
And then I wrote for myself in Delphi some UDP to OPC DA gateway and modified my Python app to use my proprietary UDP protocol. It is bit slower but good enough for me.