Microsoft KB Archive/193724

= PRB: Memory Leak Passing Arrays from VBScript to VFP =

Article ID: 193724

Article Last Modified on 7/1/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q193724



SYMPTOMS
When passing an array from VBScript code to a Visual FoxPro Component Object Model (COM) Server, memory usage increases.



CAUSE
For every STRING or UNITIALIZED array element, you lose one handle and 8 bytes of memory.



RESOLUTION
The following workaround initializes all elements of the array with numeric data or Null before sending it to the COM Server. <%@ LANGUAGE=VBScript ENABLESESSIONSTATE=False %> This is a test

<% dim myarray(30) for i = 0 to 29 myarray(i) = 0 'Or Null next

set ox = Server.CreateObject("arrayhandler.arrayhandler") response.write ox.myeval("' '+vers(1)+' '+time+" + _ "' '") response.write ox.myeval("' UserMem:'+sys(1016) + ' '")

ox.DoNothingToArray myarray

set myarray(2) = NOTHING set myarray(0) = NOTHING set myarray(1) = NOTHING

set ox = NOTHING set zzz = NOTHING

%>



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
  In a project named ArrayHandler, add the following code to the Main program: DEFINE CLASS arrayhandler AS CUSTOM OLEPUBLIC PROCEDURE DoNothingToArray PARAM myarray EXTERNAL ARRAY myarray RETURN ENDPROC PROC mydocmd(p1) &p1 PROC myeval(p1) RETURN EVAL(p1) ENDDEFINE  Build that project into a COM .dll file named ArrayHandler.dll.  Use the following code in an Active Server Page called ArrayTest.asp: <%@ LANGUAGE=VBScript ENABLESESSIONSTATE=False %> <% dim myarray(30) myarray(0) = "blah"

set ox = Server.CreateObject("arrayhandler.arrayhandler") response.write ox.myeval("' '+vers(1)+' '+"+ _ "time + ' '") response.write ox.myeval("' UserMem:'+sys(1016) + ' '")

ox.DoNothingToArray myarray

set myarray(2) = NOTHING set myarray(0) = NOTHING set myarray(1) = NOTHING

set ox = NOTHING set zzz = NOTHING

%>                        Place the ArrayHandler.dll on a computer that has Internet Information Server (IIS) and register the COM server. Place the Active Server Page created in Step 3 in the InetPub\WWWRoot directory on the IIS Server.</li> Run the .asp page by typing the following in the Address line of Internet Explorer on the IIS Server and then press ENTER: http://LOCALHOST/ARRAYTEST.ASP</li></ol>

When the page displays, press the F5 key to refresh. Notice the memory increase with each refresh.

Additional query words: kbVFp600 kbCOMt kbISAPI kbInternet kbVBScript

Keywords: kbprb kbpending kbcode KB193724

-

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

© Microsoft Corporation. All rights reserved.