Microsoft KB Archive/197206

= PRB: Slight Memory Leak Calling VFP COM DLL Repeatedly from VFP =

Article ID: 197206

Article Last Modified on 8/3/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q197206



SYMPTOMS
When you repeatedly call a COM DLL created in Visual FoxPro, the memory usage of Visual FoxPro increases slightly.



CAUSE
The memory usage increase between calls to the COM DLL is greater in Visual FoxPro 5.x than in Visual FoxPro 6.0. In Visual FoxPro 5.x, increases of 100K or more are common. In Visual FoxPro 6.0, the memory increases normally range from 4K to 16k.

The problem appears to be related to returning long character strings back from the COM DLL.



Steps to Reproduce Behavior
The Steps to Reproduce Behavior require that you use a Windows NT computer.

NOTE: If you run this on a different computer (not the one where you built the COM DLL), then you need to register it using Regsvr32.exe.

 Create a new project. Name it Test. Add a new program to the project. Name this Test.prg. Place the following code in Test.prg and save it:

DEFINE CLASS ObjectTest AS CUSTOM OLEPUBLIC FUNCTION MyGetObject RETURN REPLICATE( "D", 65000 ) ENDFUNC ENDDEFINE

 Build the project into a COM DLL. Create another new program. Name it Dotest.prg. Do not include it in the project. Place the following code in Dotest.prg and save it:

x = CreateObject("test.ObjectTest") FOR i = 1 TO 10 x.MyGetObject NEXT i     x = .NULL.

</li> Keep the Dotest.prg file open in Visual FoxPro.</li> Open the Windows NT Task Manager. Click the Process tab. Make sure the Mem Usage column is displayed. Find the Visual FoxPro executable file - VFP6.exe or VFP.exe. Note the Mem Usage number.</li> Run the Dotest.prg program repeatedly by clicking on the Run ToolButton on the Standard toolbar.</li></ol>

RESULT: Note that the Mem Usage number jumps up and then comes back down each time. However, each time it comes back down, it is higher than it was previously. With Visual FoxPro 6.0, it is normally about 4k higher each time. This might vary between 2k and 16k higher. In Visual FoxPro 5.x, the Mem Usage increases by 100k or more each time you run the program.

Keywords: kboop kbprb kbpending KB197206

-

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

© Microsoft Corporation. All rights reserved.