How To Limit Virtual Memory for a Win32s Application

Last reviewed: January 6, 1997
Article ID: Q147434
The information in this article applies to:
  • Microsoft Win32s version 1.30, 1.30a, 1.30c

SUMMARY

It is possible to limit the amount of virtual memory that a 32-bit application running under Win32s version 1.3c can use. This could be a potential requirement for some 32-bit applications that do not want to swap data out to the pagefile at all.

MORE INFORMATION:

In your Win32s application, you can call VirtualAlloc() to allocate all the required memory at one time and then use only this memory.

To do this, you need to adjust the working set size of your 32-bit process. Win32s partially supports the Win32 functions GetProcessWorkingSet() and SetProcessWorkingSet(). Although the hProcess and dwMinimumWorkingSetSize parameters are ignored, you can call SetProcessWorkingSet(), and set the dwMaximumWorkingSetSize to the total number of pages that your 32-bit application needs to lock in memory. This number is system wide in the Windows 3.x environment; it is not a per-process number as in Windows NT.

Next, you need to call VirtualLock() to lock the allocated pages. This way the memory will not be swapped out. Note that VirtualLock() is supported in Win32s even though the Win32 documentation says otherwise. It is also important to note that unlike in Win32, the dwMaximumWorkingSetSize parameter of SetProcessWorkingSet() function does not limit the working set size of Win32s applications. It only sets the limit on how many pages can be locked in memory (by calling VirtualLock()).


KBCategory: kbprg kbdocerr kbhowto
KBSubcategory: w32s
Additional reference words: 1.30c kbinf noswap pagefile virtual memory


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: January 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.