davidLin7692 / pymodbus

Automatically exported from code.google.com/p/pymodbus
0 stars 0 forks source link

Memory leak on TCP ModbusClient #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Following code:

import time
The program:

import logging
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
while True:
    client=ModbusClient("172.16.3.156")
    result = client.read_coils(0, 6)
    print result.bits
    client.close()

runned on: 
           python2.7
           pymodbus-1.1.0-py2.7.egg

Generates memory leaks, previous versions 0.9.0 does not have this issue.

Original issue reported on code.google.com by alexandr...@gmail.com on 13 Dec 2012 at 12:24

GoogleCodeExporter commented 9 years ago
Where you checking with any debugger in particular or do you have any traces?  
I'll look into it regardless though.

Original comment by Bashw...@gmail.com on 17 Dec 2012 at 3:11

GoogleCodeExporter commented 9 years ago
I just read the python gc documentation and found out a nice nugget: if a cycle 
contains a __del__ method, the gc will not be able to collect it.  Guess what 
contains a __del__ method? BaseModbusClient.  The bug is now fixed in the head 
branch on github: http://docs.python.org/2/library/gc.html

Original comment by Bashw...@gmail.com on 17 Dec 2012 at 3:52