Loop is eating my memory.

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
robert
Posts: 6
Joined: Wed Apr 27, 2011 9:25 am

Re: Loop is eating my memory.

Post by robert » Wed Jun 01, 2011 7:43 pm

Hi again,

after almost giving up I sent an email to Barry who developed OpenOPC.
He had a look at my code and here is his answer:
Robert,

I just looked briefly at your code and noticed that you are not using a named OPC group when calling the opc.read() function.

Some users have experienced a slow memory leak when repeatedly calling opc.read() without specifying an explicit group name. When no group name is specified, the function will automatically create an OPC group and then destroy it before the function exists.

But by using a named OPC group which you re-use each time, you will avoid the repeated creation/destruction cycle and the memory leak should disappear.

The first time through any loop do your read call like this....

opc.read(tags, group='MyGroup')

Then all subsequent times call read like this....

opc.read(group='MyGroup')

The OPC group will be reused each time, re-fetching the values for the same tag list.
After implementing his suggestions everything works the way it should, no more memory leak.

Big thanks to Krambriw for trying to help me.

Best regards
Robert

Post Reply