| 1 | X-Account-Key: account2
|
|---|
| 2 | X-UIDL: <48B2EC31.2010603@sygyt.com>
|
|---|
| 3 | X-Mozilla-Status: 0011
|
|---|
| 4 | X-Mozilla-Status2: 00000000
|
|---|
| 5 | Return-Path: <bodo.maass@sygyt.com>
|
|---|
| 6 | Received: from ispmxaamta06-gx.windstream.net ([85.13.138.168])
|
|---|
| 7 | by ispmxmta12-srv.windstream.net with ESMTP
|
|---|
| 8 | id <20080825173038.WDZE8427.ispmxmta12-srv.windstream.net@ispmxaamta06-gx.windstream.net>
|
|---|
| 9 | for <gidluck@alltel.net>; Mon, 25 Aug 2008 12:30:38 -0500
|
|---|
| 10 | Received: from dd18200.kasserver.com ([85.13.138.168])
|
|---|
| 11 | by ispmxaamta06-gx.windstream.net with ESMTP
|
|---|
| 12 | id <20080825173037.NQUO20036.ispmxaamta06-gx.windstream.net@dd18200.kasserver.com>
|
|---|
| 13 | for <gidluck@alltel.net>; Mon, 25 Aug 2008 12:30:37 -0500
|
|---|
| 14 | Received: from [192.168.1.101] (host218-51-dynamic.5-87-r.retail.telecomitalia.it [87.5.51.218])
|
|---|
| 15 | by dd18200.kasserver.com (Postfix) with ESMTP id 196B81819201B;
|
|---|
| 16 | Mon, 25 Aug 2008 19:30:34 +0200 (CEST)
|
|---|
| 17 | Message-ID: <48B2EC31.2010603@sygyt.com>
|
|---|
| 18 | Date: Mon, 25 Aug 2008 19:30:25 +0200
|
|---|
| 19 | From: Bodo Maass <bodo.maass@sygyt.com>
|
|---|
| 20 | Organization: Sygyt Software
|
|---|
| 21 | User-Agent: Thunderbird 2.0.0.16 (Windows/20080708)
|
|---|
| 22 | MIME-Version: 1.0
|
|---|
| 23 | To: Gordon Gidluck <gidluck@alltel.net>, portaudio@techweb.rfa.org
|
|---|
| 24 | Subject: Re: [Portaudio] CreateThread vs. _beginthreadex in WMME
|
|---|
| 25 | References: <48AEBD7D.9030802@sygyt.com> <010501c90661$30e3a730$0b00a8c0@rossmacbook> <48B2CC36.7050108@alltel.net>
|
|---|
| 26 | In-Reply-To: <48B2CC36.7050108@alltel.net>
|
|---|
| 27 | Content-Type: text/plain; charset=ISO-8859-1; format=flowed
|
|---|
| 28 | Content-Transfer-Encoding: 7bit
|
|---|
| 29 | X-Cloudmark-Analysis: v=1.0 c=1 a=FzLEsc44_lMA:10 a=4ahWgtOr4jAA:10 a=k9yv4BZYgbxZf3bBnjXcVA==:17 a=yMhMjlubAAAA:8 a=BDktQ--kAAAA:8 a=0Wz6Fd-ORsKiX3WLP_gA:9 a=sKQ_6hjfOoFoJ_UJY8cA:7 a=zBKqr-RwKcVZFK4-uJO3COstrCAA:4 a=7RhDnMDjS-4A:10 a=50e4U0PicR4A:10
|
|---|
| 30 |
|
|---|
| 31 | Hi Gordon,
|
|---|
| 32 |
|
|---|
| 33 | _beginthreadex is a function from the runtime library, and CreateThread
|
|---|
| 34 | is from the Win32 API, so I wouldn't think that Microsoft could have
|
|---|
| 35 | fixed the issue.
|
|---|
| 36 | But I will create a simple test app to reproduce the memory leak
|
|---|
| 37 | mentioned, and then we can see if the problem still happens in VC 2005
|
|---|
| 38 | and 2008. I am travelling this week, so I'll post my results here
|
|---|
| 39 | sometime next week.
|
|---|
| 40 |
|
|---|
| 41 | Bodo
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | Gordon Gidluck schrieb:
|
|---|
| 45 | > Bodo and Ross,
|
|---|
| 46 | >
|
|---|
| 47 | > To me it does not make sense to change this unless it is still a
|
|---|
| 48 | > problem. Since the article is over three years old, perhaps Microsoft
|
|---|
| 49 | > has fixed this in Visual Studio 2005 and 2008. ???
|
|---|
| 50 | >
|
|---|
| 51 | > _beginthead is not supported in embedded Visual C++ 3 and 4 for native
|
|---|
| 52 | > code development, but it seems that _beginthread could be statically
|
|---|
| 53 | > linked from an older library.
|
|---|
| 54 | >
|
|---|
| 55 | > Gordon
|
|---|
| 56 | >
|
|---|
| 57 | > Ross Bencina wrote:
|
|---|
| 58 | >> Hi Bodo
|
|---|
| 59 | >>
|
|---|
| 60 | >> I've always wondered about this. I don't think it is deliberate, just
|
|---|
| 61 | >> a bad habit & ignorance of one of the developers (me).
|
|---|
| 62 | >>
|
|---|
| 63 | >> Are you experienced with the use of _beginthread/_beginthreadex ? Do
|
|---|
| 64 | >> you know if it is portable to all Win32/Win64 compilers?
|
|---|
| 65 | >>
|
|---|
| 66 | >> Ross.
|
|---|
| 67 | >>
|
|---|
| 68 | >>
|
|---|
| 69 | >>
|
|---|
| 70 | >>
|
|---|
| 71 | >> ----- Original Message ----- From: "Bodo Maass" <bodo.maass@sygyt.com>
|
|---|
| 72 | >> To: <Portaudio@techweb.rfa.org>
|
|---|
| 73 | >> Sent: Friday, August 22, 2008 11:22 PM
|
|---|
| 74 | >> Subject: [Portaudio] CreateThread vs. _beginthreadex in WMME
|
|---|
| 75 | >>
|
|---|
| 76 | >>
|
|---|
| 77 | >>
|
|---|
| 78 | >>> Hi,
|
|---|
| 79 | >>>
|
|---|
| 80 | >>> I noticed that the processing thread that calls the user callback in
|
|---|
| 81 | >>> wmme is created with the CreateThread function instead of the
|
|---|
| 82 | >>> recommended _beginthread or _beginthreadex.
|
|---|
| 83 | >>>
|
|---|
| 84 | >>> The beginthread methods set up the runtime library for that thread and
|
|---|
| 85 | >>> then call CreateThread internally. Failure to do that may lead to a
|
|---|
| 86 | >>> small memory leak when the thread finishes:
|
|---|
| 87 | >>> http://support.microsoft.com/default.aspx/kb/104641
|
|---|
| 88 | >>>
|
|---|
| 89 | >>> Now, in portaudio, the processing thread calls a user defined callback
|
|---|
| 90 | >>> function, which may well call some functions of the runtime library
|
|---|
| 91 | >>> (it's hard not to), and this may cause the memory leak mentioned in the
|
|---|
| 92 | >>> MS article.
|
|---|
| 93 | >>>
|
|---|
| 94 | >>> Is the use of CreateThread at this place deliberate? If not, I would
|
|---|
| 95 | >>> recommend changing it to _beginthreadex.
|
|---|
| 96 | >>>
|
|---|
| 97 | >>> Best wishes,
|
|---|
| 98 | >>> Bodo
|
|---|
| 99 | >>>
|
|---|
| 100 | >>>
|
|---|
| 101 | >>> _______________________________________________
|
|---|
| 102 | >>> Portaudio mailing list
|
|---|
| 103 | >>> Portaudio@techweb.rfa.org
|
|---|
| 104 | >>> http://techweb.rfa.org/mailman/listinfo/portaudio
|
|---|
| 105 | >>>
|
|---|
| 106 | >>>
|
|---|
| 107 | >>
|
|---|
| 108 | >> _______________________________________________
|
|---|
| 109 | >> Portaudio mailing list
|
|---|
| 110 | >> Portaudio@techweb.rfa.org
|
|---|
| 111 | >> http://techweb.rfa.org/mailman/listinfo/portaudio
|
|---|
| 112 | >>
|
|---|
| 113 | >>
|
|---|
| 114 | >
|
|---|
| 115 |
|
|---|