There are many different types of memory. There is short term memory, and long term memory. There is the remembrance of things past, and remembrance of things to come.
Windows allocates its memory in heaps. The size of some of these heaps of memory are hard coded into Windows itself. This will change, they say, once NT comes out, but as for now we are stuck with the hard coded limits built into Windows.
WIN sets aside only 256 K of memory for Graphic Device Interface memory, the memory used to define screen objects. This amount is double what was set aside in WIN 3.0--but it is still not enough. You can easily run out of memory without any warning. And the old MEMORY() function will still report back that you have 640K available.
For example if you wish to define hundreds of windows on your screen in FoxPro for DOS you will have no problem. Windows, on the other hand has much more severe limitations. The maximum number of Windows I was able to define was 54. This is because of the GDI Memory that is hard coded into Windows.
The problem is that there is no way to tell in native FoxPro how much memory is left. Therefor you have to use the WINDOWS API functions to get Windows itself to report back the percentage of system resources available. This is the same figure that is returned from the Program Manager Help screen. FoxPro will fail when this figure falls below 19% of system resources. To do this you have to use the FOXTOOLS library that comes with the product. How Foxtools works is beyond the scope of this article, but the functions included in your GOODIES sub directory will give you a good idea of how this works.
We are putting together a library API functions. If you are interested you should contact FoxMasters at (800) 93-FOXPRO or on CIS at 74007,2011.
The sample program, MEMORY.PRG will define windows on your screen until you run out of GDI memory. Each window has the amount of GDI and other types of memory printed in it. To get rid of these windows issue a CLEAR ALL from the command windows
ABOUT THE AUTHOR
Bruce Braunstein is Editor of FoxMasters Magazine-The First FoxPro Magazine on a disk. He is also the author of numerous SF books including The Magenta of Cyan, The Cars of the Stars, Baby Penrose, and Disneyland Vs. Deutschland. These books are available from Tetra Press which also publishes FoxMasters.