PRB: GetFreeSpace Returns Physical Memory Not Free Heap Space

Last reviewed: September 27, 1995
Article ID: Q137290
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) version 3.1

SYMPTOMS

The GetFreeSpace API no longer returns the amount of free space on the global system heap.

CAUSE

Because Windows 95 implements virtual memory, the system heap is effectively unlimited. Returning the practical amount of free memory would cause unpleasant side effects in applications that assume the return value is limited to physical memory. Therefore, GetFreeSpace returns the amount of free space on the heap -- up to the amount of physical memory in the computer.

RESOLUTION

Do not depend on GetFreeSpace returning the amount of free space in the heap. It will not.

STATUS

This behavior is by design.

MORE INFORMATION

In particular, GetFreeSpace does not work with code that loops as shown in this pseudo code:

   while (there is still free memory)
      give it to me;

This programming practice is not supported. Applications must share system resources with each other. Applications can minimally use GetFreeSpace to determine a reasonable amount of memory to allocate for the current computer given their working set requirements.

NOTE: Win32-based applications should use GlobalMemoryStatus.


Additional reference words: 4.00
KBCategory: kbprg kbprb
KBSubcategory: BseMm


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 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.