Microsoft KB Archive/165067

= FIX: Memory Leak Using CLEAR ALL on Subclass with Array =

Article ID: 165067

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition

-



This article was previously published under Q165067



SYMPTOMS
The CLEAR ALL command does not recover memory after altering the array property of a class from a subclass. Because the CLEAR ALL command does not recover the memory, running the program numerous times may cause the Visual FoxPro application to exhaust system memory resources.

This problem does not occur in Visual FoxPro for Windows 3.0b.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 5.0a for Windows.



Steps to Reproduce Behavior
Create a program file, add the following code, and execute it. * 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

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.