PRB: Insufficient Memory Encountered When Creating Windows

Last reviewed: June 27, 1995
Article ID: Q126838
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

SYMPTOMS

Defining and activating windows causes an "Insufficient memory" error message.

CAUSE

The number of windows which can be created and activated is limited by the amount of available Windows GDI resources. This clarifies article Q106268 which states that the maximum number of open windows is limited by the

'amount of memory and available file handles.' This amount of memory is not
actual physical memory, but rather the Graphical Device Interface (GDI) resources available in Windows.

Exceeding the available GDI resources may result in an "Insufficient Memory" message. This behavior does not exist on machines running Windows NT because GDI resources are dynamically allocated, which means that the maximum number of windows is limited by the amount of memory.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

The program below will do the following:

  1. Display the available GDI resources prior to defining and activating a number of windows;

  2. Display the last window which was able to be activated prior to the "Insufficient Memory" message.

  3. Display the available GDI resources at the point of the "Insufficient Memory" message.

NOTE: The WAIT WINDOWs are timed so that the program will run without intervention.

   CLEAR ALL
   CLEAR
   #DEFINE GDIRESO 0

   SET LIBRARY TO SYS(2004)+'foxtools.fll' ADDITIVE
   DO resources
   ON ERROR DO sysreport WITH MESSAGE()

   FOR x =1 TO 1000
      y='n'+ALLTRIM(STR(x))
      DEFINE WINDOW &y AT x/20,x/10 SIZE 5,5 TITLE y
      ACTIVATE WINDOW &y
   ENDFOR

   PROCEDURE sysreport
   PARAMETER mess
   DEACTIVATE WINDOW ALL
   WAIT WINDOW mess TIMEOUT 5
   DO resources
   CANCEL
   RETURN

   PROCEDURE resources
   getsysres=REGFN('GetFreeSystemResources', 'I','I')
   IF getsysres > -1
      x=CALLFN(getsysres, gdireso)
      WAIT WINDOW 'Current System Resources are: ' + ;
         STR(x,3,0)+'%' TIMEOUT 3

   ENDIF
   RETURN

   CLEAR ALL


Additional reference words: 2.60a FoxWin errmsg
KBCategory: kbprg kberrmsg kbprb
KBSubcategory: FxprgUdwindow


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