[python-win32] python-win32 Digest, Vol 122, Issue 5
Michael Watson
michaelwtsn4 at gmail.com
Mon May 6 17:15:19 CEST 2013
Thank you. I have tried both del() and setting the value to None. Neither
worked.
On May 6, 2013 6:25 AM, <python-win32-request at python.org> wrote:
> Send python-win32 mailing list submissions to
> python-win32 at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
> python-win32-request at python.org
>
> You can reach the person managing the list at
> python-win32-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
> 1. Re: Memory Leak in Threaded COM Object [SEC=UNOFFICIAL]
> (Andrew MacIntyre)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 6 May 2013 01:01:24 +0000
> From: "Andrew MacIntyre" <Andrew.MacIntyre at acma.gov.au>
> To: "python-win32 at python.org" <python-win32 at python.org>
> Subject: Re: [python-win32] Memory Leak in Threaded COM Object
> [SEC=UNOFFICIAL]
> Message-ID:
>
> <A1E4E9D08D14924498E135FB4441EE8D92F9BAD5 at act01exmbx01vp.internal.govt>
>
> Content-Type: text/plain; charset="us-ascii"
>
> Stab in the dark: after calling the Clear() method on object "tom" in
> method CreateTom, use "del tom" or "tom = None" to try and lose any remnant
> COM references before pythoncom.CoUninitialize() is called.
>
> -------------------------> "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.macintyre at acma.gov.au<mailto:andrew.macintyre at acma.gov.au>
> http://www.acma.gov.au/
>
> From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=
> acma.gov.au at python.org] On Behalf Of Michael Watson
> Sent: Saturday, 4 May 2013 8:05 AM
> To: python-win32 at python.org
> Subject: [python-win32] Memory Leak in Threaded COM Object
>
>
> I am creating a COM client within a thread and performing several
> operations with this client. Each thread is spawned from a server that uses
> Python's socketserver module which has built-in threading support.
>
> When I am loading and using this COM object there is an expected spike in
> memory usage by python.exe. With 10 concurrent threads there is a peak in
> memory usage of about 500Mb. However when the operations are finished and
> the COM object is apparently released, there are 50Mb of additional memory
> used by the process than before. If I then spawn 10 additional threads
> using the same server there are 13Mb additional used by python.exe after
> those COM objects are closed. Eventually every 10 additional concurrent
> threads adds approximately 6Mb after they are done. When I end the entire
> python.exe process, all the memory is released.
>
> I have simplified the following code to mimic how the socketserver uses
> threadding and the problem is the exact same.
>
> import win32com.client
>
> import threading
>
> import pythoncom
>
>
>
> def CreateTom():
>
> pythoncom.CoInitialize()
>
> tom = win32com.client.Dispatch("TOM.Document")
>
> tom.Dataset.Load("FileName")
>
> tom.Clear()
>
> pythoncom.CoUninitialize()
>
>
>
> for i in range(50):
>
> t = threading.Thread(target = CreateTom)
>
> t.daemon = False
>
> t.start()
>
> I understand that I will unlikely get any support here around the specific
> COM library (it is an IBM product used in Market Research known as the
> TablesObjectModel). However I want to know if there is anything, ANYTHING,
> additional that I can do to release this memory. I have read about
> Apartments in COM but it sounds like pythoncom.CoInitialize should take
> care of this for me. Any help would be appreciated.
>
> 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.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-win32/attachments/20130506/219c365e/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> ------------------------------
>
> End of python-win32 Digest, Vol 122, Issue 5
> ********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20130506/f6c80093/attachment.html>
More information about the python-win32
mailing list