BUG: Application Error When Accessing Cursors/Tables in Loop (253938)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q253938 SYMPTOMS
When you are creating cursors and changing the cursor names in a loop, after about 32,160 cursor name changes, Visual FoxPro generates an error message and shuts down. The error message can be:
Fatal Error: Exception code=C00000005
Alias '' is not found.
This is followed by the error message:
Fatal Error.
CAUSE
The use of macro expansion/variable substitution, in conjunction with the use of macro expansion/variable substitution to access the table, causes this problem. For example:
lcAlias = "A" + ALLTRIM(STR(x))
CREATE CURSOR (lcAlias) (fld1 c(10))
cValue = &lcAlias..fld1
lcAlias = SYS(2015)
USE Table1 ALIAS &lcAlias
cValue = &lcAlias..fld1
The more instances of macro expansion/variable substitution, the sooner the problem occurs. However, the problem only occurs when a table/cursor is USEd/CREATEd with macro substitution/variable substitution.
RESOLUTION
Use constant alias names. Do not change the name of the alias each time it is created. For example, when you create a cursor in a loop, use the same name each time instead of using a unique name.
LOCAL lcAlias, x
CLEAR
@ 2,1 SAY "Starting User Object Memory Use"
@ 3,1 SAY SYS(1016) && User Object Memory Use
@ 4,1 SAY "Current User Object Memory Use"
FOR x = 1 TO 100000
lcAlias = "ABCDEF"
CREATE CURSOR (lcAlias) (fld1 c(10))
cValue = &lcAlias..fld1
USE IN (lcAlias)
@ 1,1 SAY lcAlias
@ 5,1 SAY SYS(1016) && User Object Memory Use
ENDFOR
RETURN
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 5/10/2003 |
---|
Keywords: | kbBug kbDatabase kbpending KB253938 |
---|
|