The information in this article applies to:
SYMPTOMSIf the CMultiLock class is used to synchronize on more than eight synchronization objects, a memory leak occurs when using CEvent, CSemaphore, or CMutex as the synchronization objects. The size of the leak equals the number of synchronization objects used multiplied by the memory needed for a BOOL variable. CAUSEThe CMultiLock class uses two arrays to keep a track of the handles of the synchronization objects and their signaled status. As an optimization, local arrays (class data members) are used if the CMultiLock class is used to synchronize on eight or fewer synchronization objects. If more than eight objects are used, memory is allocated at run time by making a call to new. The CMultiLock destructor frees the memory associated with the handles array but not the memory associated with the signaled status array. RESOLUTION
Working around the memory leak is difficult, because it is not possible to
derive a class from CMultiLock and delete the array in destructor. This
behavior occurs because CMultiLock's destructor, called after the derived
class's destructor, uses this array to unlock the objects. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 32- bit Edition version 4.2. MORE INFORMATIONSample CodeThe following code reproduces the problem:
Additional query words: kbVC400bug 4.00 4.10 4.20 CSemaphore CmutexCEvent vcfixlist420 MfcThreadIss
Keywords : kbMFC kbThread kbVC |
Last Reviewed: July 26, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |