Q102113: FIX: "Out of Virtual Memory" Message may be Caused by chdir()
Article: Q102113
Product(s): Microsoft C Compiler
Version(s): 1.00 2.00
Operating System(s):
Keyword(s): kbCRT kbVCkbbuglist
Last Modified: 26-JUL-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Visual C++, versions 1.0, 2.0
-------------------------------------------------------------------------------
SYMPTOMS
========
When you run an application that calls the chdir() function many times, an "Out
of Virtual Memory" error may occur. You may also notice that the page file grows
continuously as the application executes.
CAUSE
=====
The chdir() function allocates a small amount of memory each time it is called.
When the function successfully completes execution, it does not free the memory
and causes a small memory leak. Because no application accesses the memory, it
is eventually swapped into the page file. The "Out of Virtual Memory" error
occurs when the page file cannot grow any larger.
RESOLUTION
==========
An application developed for the Win32 or Win32s operating systems can avoid the
memory leak by using the SetCurrentDirectory() function. SetCurrentDirectory()
changes the current directory for the current process.
STATUS
======
Microsoft 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++ version 2.1.
Additional query words: 1.00 2.00 8.00 9.00
======================================================================
Keywords : kbCRT kbVC kbbuglist
Technology : kbVCsearch kbAudDeveloper kbvc100 kbVC200
Version : 1.00 2.00
Issue type : kbbug
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.
Copyright Microsoft Corporation 1986-2002.