Knowledge Base

PRB: Too Many Memory Variables Error Creating Array

Article ID: 191170

Article Last Modified on 5/12/2003


APPLIES TO


This article was previously published under Q191170

SYMPTOMS

The following error may occur when you run code in an application:
Too many memory variables.

CAUSE

Using a SELECT-SQL command or another method to create a array that is larger than 65000 elements.

RESOLUTION

Make sure that the array is less than the 65000 element limit of Visual FoxPro.

STATUS

This behavior is by design.

MORE INFORMATION

Visual FoxPro and earlier versions of the FoxPro product have a limit of 65000 memory variables and 65000 elements in a array. FoxPro treats each element of an array as an individual memory variable. Therefore, when the number of array elements (number of rows multiplied by the number of columns) exceeds 65000, the error occurs. However, if the size of the table fluctuates, then this error may appear intermittently and is therefore difficult to troubleshoot. Since this is a system limitation of FoxPro and Visual FoxPro, increasing the value of the MVCOUNT system variable in the Config.fpw (or Config.fpm) does not prevent the error.

Steps to Reproduce Behavior

  1. Create a table that has 21667 records each containing three fields. Please refer to the article listed in the REFERENCES section for an example of creating large tables for testing purposes.
  2. After creating the table in step 1, type the following command in the Command window:
          SELECT  * FROM lartable INTO ARRAY test
    							
    This line of code assumes that the table name is Lartable. The error appears immediately.

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

170128 HOWTO: Programmatically Create Large Tables for Testing Purposes

Visual FoxPro Help; search on: "Visual FoxPro System Capacities"

FoxPro Help; search on: "System Capacities"

Additional query words: kbVFp300b kbVFp500 kbVFp500a kbXBase kbVFp600

Keywords: kbprb KB191170