The information in this article applies to:
SUMMARY
When an application requires memory for a particular purpose, it
should request that amount of memory from the system. If a given
request fails, the application can present an error message to the
user, or make a smaller request.
MORE INFORMATIONIn enhanced-mode Windows, determining the amount of free system memory is a very complex problem because Windows uses virtual memory. There are also a number of different types of memory that are used for specific purposes. The following list enumerates some of these memory options: DDE shareThe presence of any of these attributes will affect the amount of free memory. It has been suggested that to attempt an allocation and then properly handle failure by potentially trying another allocation is too slow. However, it is doubtful that any method of calculating available memory will be any faster (if such a calculation was even possible). An overriding complication is that any memory use in another application or in a virtual machine will invalidate any computed value. An excellent discussion about dealing with varying amounts of system memory is in Chapter 18 of "Peter Norton's Windows 3 Power Programming Techniques" (Bantam Books, 1990) beginning on page 661. Given the caveats above, it is possible to obtain a very rough estimate of free system memory. Two routines report this information: the GlobalCompact() API and the MS-DOS Protected Mode Interface (DPMI) function 0500h (get free memory information). There are two pools of memory in enhanced-mode Windows:
The first line of code determines available memory according to both memory
managers. The second line accounts for the limitation imposed by the
GlobalAlloc() API, which sets the maximum size of a segment at (16
megabytes minus 64 kilobytes). The GlobalCompact() API does require a lot
of processing time, especially in standard (286 protect) mode.
Additional query words: no32bit 3.00 3.10
Keywords : kb16bitonly |
Last Reviewed: November 4, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |