FIX: OnIdle() Processing Can Hang in Low-Memory Situations

Last reviewed: September 18, 1997
Article ID: Q116135
1.00 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with: Microsoft Visual C++ for Windows, version 1.0

SYMPTOMS

An application that uses the Microsoft Foundation Class (MFC) library might hang in situations where memory is extremely low.

CAUSE

The MFC library does idle-time processing to attempt to reclaim available memory for its safety memory pool. This processing is done in CWinApp::OnIdle() at approximately line 540 in the module APPCORE.CPP. OnIdle() uses a while loop to attempt to reclaim this memory. However, if the available memory is sufficiently low, the entire pool cannot be reclaimed and the while loop never exits, hanging the application.

RESOLUTION

To avoid the potential problem, do one of the following:

  • Upgrade to Visual C++ for Windows, version 1.5, because the problem has been fixed in the MFC Library, version 2.5.

    -or-

  • Modify the code in the APPCORE.CPP module to use an if statement instead of a while statement, and rebuild the MFC library. For example, the code at line 540 in the APPCORE.CPP module should be changed from:

          while ((m_pSafetyPoolBuffer == NULL ||
    
             _msize(m_pSafetyPoolBuffer) < m_nSafetyPoolSize) &&
            m_nSafetyPoolSize != 0)
    
       to the following:
    
          if ((m_pSafetyPoolBuffer == NULL ||
               _msize(m_pSafetyPoolBuffer) < m_nSafetyPoolSize) &&
              m_nSafetyPoolSize != 0)
    
    

STATUS

Microsoft has confirmed this to be a problem in Visual C++ for Windows, version 1.0. This problem was corrected in Visual C++ 1.5.

This is not a problem in Visual C++ 32-bit Edition.

MORE INFORMATION

For more information regarding building the MFC library, refer to Appendix B in the "MFC User's Guide," provided with Visual C++ for Windows, version 1.0.


Additional reference words: runtime infinite loop 1.00 2.00
KBCategory: kbprg kbfixlist kbbuglist
KBSubcategory: MfcMisc
Keywords : kb16bitonly MfcMisc kbbuglist kbfixlist kbprg
Technology : kbMfc
Version : 1.00
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.