Article ID: 165067
Article Last Modified on 10/16/2002
* This program illustrates a memory leak in Visual FoxPro 5.0:
* If an array property of a class is altered in a subclass
* then there is a memory leak with each instantiation of the
* subclass.
* The loop demonstrates the memory leak: Every instantiation of
* a test1 class will use memory not recoverable by CLEAR ALL.
FOR lncounter=1 TO 500
oa=CREATEOBJ("test1")
_PAGENO=lncounter
CLEAR ALL
WAIT WINDOW NOWAIT "Test "+ALLT(STR(_PAGENO,6))+": ;
Memory used"+ALLTRIM(SYS(1016))
lncounter=_PAGENO
ENDFOR
CLEAR ALL
RETURN
* DO-NOTHING CLASSES which demonstrate the memory leak.
DEFINE CLASS objectWithArray AS LINE
DIMENSION atest[1]
atest[1]=""
p1="base value for p1"
ENDDEFINE
DEFINE CLASS Test1 AS objectWithArray
DIMENSION atest[4]
atest[1]="p1"
atest[2]="p2"
atest[3]="a1"
atest[4]="a2"
p1="default for p1"
p2="default for p2"
ENDDEFINE
* End of test loop program
While the program runs under Visual FoxPro 5.0, notice the memory usage
reported by the SYS(1016) function continues to increase. However, no
increase in memory usage appears when the code runs under Visual FoxPro
5.0a for Windows.
Additional query words: execute executing
Keywords: kbbug kbfix kbvfp500afix KB165067