[sorry for top post] CPython uses reference counting; when the reference count drops to 0, the object is deleted and its memory returned to the heap.
CPython’s garbage collector is there to attempt to resolve situations where the reference count is not being allowed to drop to 0 (such as via circular references). CPython’s garbage collector isn’t the same as garbage collection in other languages (such as Java). Setting a variable to None in CPython will definitely force an object to be deleted if its reference count drops to zero. The garbage collector has an additional function (run as a side-effect) which may give the impression of delayed cleanup – when it is run, it checks the state of Python’s private memory allocator, and if there are unused memory chunks in the private heap it will return them to the OS. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macint...@acma.gov.au<mailto:andrew.macint...@acma.gov.au> http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov...@python.org] On Behalf Of Randy Syring Sent: Wednesday, 12 September 2012 12:09 AM To: python-win32@python.org Subject: Re: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] I'm not sure how this applies to COM and the python interface to it, but just setting a value to None doesn't usually force the object to go away in Python. That won't happen until it is garbage collected, which you can force if needed: http://docs.python.org/library/gc.html --------------------------------------------- Randy Syring Development & Executive Director Level 12 Technologies<https://www.lev12.com/> Direct: 502-276-0459 Office: 502-212-9913 Principled People, Technology that Works On 09/11/2012 09:35 AM, Matteo Boscolo wrote: I try with both method but with no result: the code is this : def GerPropValue2(self,name): try: oiDoc,ent=self._getCurrentEnt if ent!=None: props=ent.Properties(True) return "aaa" # Go out here for testing pourpuse for i in range(0, len(props)): # check the len it could give some error logging.debug('_getProp : property found %s',str(props[i].Parent.Name)) if props[i].Parent.Name==name: return props[i].Value return None finally: del ent del props del oiDoc props=None tdProp=None oiDoc=None ent=None there is any way to debug how is the object deleted ? regards, Matteo Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: [sorry for top-post] You probably need to release the Python object that is wrapping the COM object. Given a variable x holding a COM object reference, either: del x or x = None should force release of any COM object reference. Which to use depends on taste and context – the latter approach for example being perhaps more usual when dealing with object attributes. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macint...@acma.gov.au<mailto:andrew.macint...@acma.gov.au> http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov...@python.org] On Behalf Of Matteo Boscolo Sent: Tuesday, 11 September 2012 4:00 AM To: python-win32@python.org<mailto:python-win32@python.org> Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? Hi All, I'm Working on a cad program using the it's com interface I have a python com object in witch I call a method as follows .. props=ent.Properties(True) #Ent is a IDocument this method is working well, and return a tuple of ITDProperty that are the property of the document. The problem is when I close the document from the Cad application, the Cad application is unable to close the document because there is some reference still active. I tried several way using the gc.collect(), to set to null each document pointer but with no result. I tried to do the some kind of operation with c# and using the Marshal.ReleaseComObject(doc);, where doc is the IDocument, and document is released and I'm free to close it from the interface. now the question is how can I do the some staff as ReleaseComObject dose in python ? its the Release method of the IUnknown interface the right way to do that ? any hint is really appreciated, thanks Regards, Matteo NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. _______________________________________________ python-win32 mailing list python-win32@python.org<mailto:python-win32@python.org> http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32@python.org<mailto:python-win32@python.org> http://mail.python.org/mailman/listinfo/python-win32 NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32