ID: Q126838
The information in this article applies to:
Defining and activating windows causes an "Insufficient memory" error message.
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.
This behavior is by design.
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
Last Reviewed: June 27, 1995