[Portaudio] CreateThread vs. _beginthreadex in WMME
bodo.maass at sygyt.com
Mon Aug 25 13:30:25 EDT 2008
_beginthreadex is a function from the runtime library, and CreateThread
is from the Win32 API, so I wouldn't think that Microsoft could have
fixed the issue.
But I will create a simple test app to reproduce the memory leak
mentioned, and then we can see if the problem still happens in VC 2005
and 2008. I am travelling this week, so I'll post my results here
sometime next week.
Gordon Gidluck schrieb:
> Bodo and Ross,
> To me it does not make sense to change this unless it is still a
> problem. Since the article is over three years old, perhaps Microsoft
> has fixed this in Visual Studio 2005 and 2008. ???
> _beginthead is not supported in embedded Visual C++ 3 and 4 for native
> code development, but it seems that _beginthread could be statically
> linked from an older library.
> Ross Bencina wrote:
>> Hi Bodo
>> I've always wondered about this. I don't think it is deliberate, just
>> a bad habit & ignorance of one of the developers (me).
>> Are you experienced with the use of _beginthread/_beginthreadex ? Do
>> you know if it is portable to all Win32/Win64 compilers?
>> ----- Original Message ----- From: "Bodo Maass" <bodo.maass at sygyt.com>
>> To: <Portaudio at music.columbia.edu>
>> Sent: Friday, August 22, 2008 11:22 PM
>> Subject: [Portaudio] CreateThread vs. _beginthreadex in WMME
>>> I noticed that the processing thread that calls the user callback in
>>> wmme is created with the CreateThread function instead of the
>>> recommended _beginthread or _beginthreadex.
>>> The beginthread methods set up the runtime library for that thread and
>>> then call CreateThread internally. Failure to do that may lead to a
>>> small memory leak when the thread finishes:
>>> Now, in portaudio, the processing thread calls a user defined callback
>>> function, which may well call some functions of the runtime library
>>> (it's hard not to), and this may cause the memory leak mentioned in the
>>> MS article.
>>> Is the use of CreateThread at this place deliberate? If not, I would
>>> recommend changing it to _beginthreadex.
>>> Best wishes,
>>> Portaudio mailing list
>>> Portaudio at music.columbia.edu
>> Portaudio mailing list
>> Portaudio at music.columbia.edu
More information about the Portaudio