Home Bug Reports

Python seems to leak communicator objects

joshmoorejoshmoore GermanyMember Josh MooreOrganization: Glencoe Software, Inc.Project: OME, http://openmicroscopy.org
With 3.3.1, the following code:
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

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Josh,

    Thanks for reporting this.

    Regards,
    Mark
Sign In or Register to comment.