Microsoft KB Archive/191170

= PRB: Too Many Memory Variables Error Creating Array =

Article ID: 191170

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.5b for Macintosh
 * Microsoft Visual FoxPro 2.5c for Macintosh
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.6 for MS-DOS
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.6 for SCO/UNIX

-



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
 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.  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. 

