Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/171047

From BetaArchive Wiki

PRB: Insufficient Memory in FoxPro for Windows on Fast Computers

ID: Q171047

The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.6, 2.6a


Working programs in FoxPro 2.x fail with the error "Insufficient Memory" when run on newer, faster computers with clock speeds greater than 150 MHz. This problem applies to both screens with list boxes and queries, but this article addresses only the problem with FoxPro screens.

The "Insufficient Memory" error message may also occur while in Filer when changing to a local(not network) directory which contains a large number of files.

The failure also happens on both MMX and non MMX Computers. The operating system could be Windows 3.x, Windows for Workgroups 3.x, Windows 95 or Windows NT. This error does not occur in FoxPro For MS-Dos.


The current fast computers were not available for testing when FoxPro 2.x for Windows was initially released. Microsoft FoxPro for Windows, 2.x does not always work with list boxes populated from tables with more than 600 records.


At this time Microsoft does not have a good workaround; however, the following are options to consider:

  1. Upgrade the application to Visual FoxPro 3.0 or 5.0.
  2. Turn off either CMOS cache (slow) or CMOS turbo mode (very slow).
  3. Reduce the number of records to be displayed in the ListBox (under 600).
  4. Run the FoxPro applications (app) and executables (exe) on a slower computer.
  5. Using an array as the source of the list items in the list box is the best resolution for this problem. To change the screen created in the Steps to Reproduce Behavior section below, follow these steps:

    1. In the Setup Code for the screen, add the following command:

      COPY TO ARRAY aTableField FIELDS charval 
    2. Double-click the listbox on the screen while in design mode. In the List dialog box that appears, change the List Items to From Array and put aTableField in for the array name. Click OK.
    3. Save and generate the screen.
    4. Although this shouldn't be necessary, it has been reported that the array needs to be released when the screen is closed. To do this, add the following command to the Cleanup Code of the screen:

      RELEASE ALL LIKE aTableField 

Along with the preceding steps, some users have found that adding the following line to the Config.fpw file helps to solve the problem:

   MEMLIMIT = 60,2048,4098 


Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


Use the Microsoft Knowledge Base at the following URL to troubleshoot other potential causes of the "Insufficient memory" errors:

NOTE: Verify that the error is due to the processor speed by trying the code on both a fast and slow computer.

Steps to Reproduce Behavior

The following is a reproducible case where FoxPro for Windows 2.x fails with "Insufficient memory" error with a list box on a screen.

  1. Place the following code in a new program file. Save it as LarTable.prg:

       * Sample code to create and populate a large table to test your
       * program.
       * Environment area.
           CLEAR SCREEN
       * Create a large table
           CREATE TABLE LarTable (CharVal C(20), NumVal N(9))
           USE LarTable.DBF
       * NumRecords = the number of record to be put in the table.
           NumRecords= 2000
       * Note using larger numbers can take a long time.
           NumWide = LEN(ALLTRIM(STR(NumRecords)))
       * FOR LOOP to fill the table.
           FOR x  = 1 TO NumRecords
            CharString="Record "+PADL(ALLTRIM(STR(x,numwide,0)),NumWide,"0")
            INSERT INTO LarTable (CharVal,NumVal) VALUES(CharString, x)
            ? RECNO()
           CREATE SCREEN LarTable.scx NOWAIT 
  2. Add a ListBox object from the toolbar on the left of the screen.
  3. Select the From Field option button and type LarTable.Charval in the Field dialog box.
  4. Type "MyList" in the Variable text box. Click OK to close the dialog box. Resize the ListBox, if necessary.
  5. Add a Push Button in which you use Close as the prompt and select the Terminate READ on Selection check box. Enter "xyz" for the variable.
  6. Generate and run the LarTable.spr screen. It should run without error on computers slower than a 166 MHz computer.
  7. It should fail with an "Insufficient Memory" error on most computers 166 MHZ or faster. Use "mybutton" as the variable prompt.

The code generally fails when the screen loads on faster computers. This problem happens only when the table contains more than about 600 records. Try deleting all but the first 600 records:


(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Mike Fernald, Microsoft Corporation.

Additional query words: foxwin fpw MMX

Keywords          : FoxWin FxenvGeneral 
Version           : WINDOWS:2.6,2.6a
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: June 28, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.