Menu

#9 Memory leakage

v1.0 (example)
open
None
7
2016-10-31
2013-10-06
Difool
No

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)

Related

Bugs: #9

Discussion

  • Barry Barnreiter

    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:


    Status: open
    Created: Sun Oct 06, 2013 04:28 PM UTC by Difool
    Last Updated: Sun Oct 06, 2013 04:28 PM UTC
    Owner: Barry Barnreiter

    It seems to have memory leakage with OpenOPC.

    For example, the following code consume about 100ko at each iteration :

    import OpenOPCwhile 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
    )


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/openopc/bugs/9/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #9

  • Difool

    Difool - 2013-10-13

    It solves the problem.
    Thank you very much, Barry

     
  • mohsh86

    mohsh86 - 2013-12-23

    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 ?

     
    • Barry Barnreiter

      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:

      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 ?

      Status: open
      Created: Sun Oct 06, 2013 04:28 PM UTC by Difool
      Last Updated: Sun Oct 13, 2013 12:09 AM UTC
      Owner: Barry Barnreiter

      It seems to have memory leakage with OpenOPC.

      For example, the following code consume about 100ko at each iteration :

      import OpenOPCwhile 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
      )


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/openopc/bugs/9/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #9

  • jk987

    jk987 - 2015-09-30

    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
  • jk987

    jk987 - 2015-10-26

    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.

     
  • jk987

    jk987 - 2016-10-31

    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.

     

Log in to post a comment.

MongoDB Logo MongoDB