Archived
This forum has been archived. Please start a new discussion on GitHub.
Python seems to leak communicator objects
joshmoore
Germany
in Bug Reports
With 3.3.1, the following code:
prints:
However, if I add "del ic._impl" then garbage collection can reap the communicator:
prints:
Cheers,
~josh
import Ice import gc ic = Ice.initialize() ic.shutdown() ic.destroy() del ic reload(Ice) gc.collect() print "GLOBAL" print dir() print "LEFTOVER" for o in gc.get_objects(): if str(type(o)).find("Ice") > -1: print type(o)
prints:
GLOBAL ['Ice', '__builtins__', '__doc__', '__file__', '__name__', 'gc'] LEFTOVER <class 'Ice.OperationMode'> <class 'Ice.OperationMode'> <class 'Ice.OperationMode'> <class 'Ice.EndpointSelectionType'> <class 'Ice.EndpointSelectionType'> <class 'Ice.CommunicatorI'>
for x in range(100): ic = Ice.initialize() ic.shutdown() ic.destroy() del ic gc.collect()leaves 100 communicators, but only the 3 operation modes and the 2 endpoint selection types.
However, if I add "del ic._impl" then garbage collection can reap the communicator:
import Ice import gc for x in range(100): ic = Ice.initialize() ic.shutdown() ic.destroy() del ic._impl # THIS LINE ADDED del ic gc.collect() print "GLOBAL" print dir() print "LEFTOVER" for o in gc.get_objects(): if str(type(o)).find("Ice") > -1: print type(o)
prints:
<class 'Ice.OperationMode'> <class 'Ice.OperationMode'> <class 'Ice.OperationMode'> <class 'Ice.EndpointSelectionType'> <class 'Ice.EndpointSelectionType'>
Cheers,
~josh
0
Comments
-
Hi Josh,
Thanks for reporting this.
Regards,
Mark0