DOCUMENT:Q193724 01-JUL-1999 [foxpro] TITLE :PRB: Memory Leak Passing Arrays from VBScript to VFP PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0 OPER/SYS: KEYWORDS:kbGrpDSFox ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 ------------------------------------------------------------------------------- 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. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. 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 2. Build that project into a COM .dll file named ArrayHandler.dll. 3. 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 %> 4. Place the ArrayHandler.dll on a computer that has Internet Information Server (IIS) and register the COM server. 5. Place the Active Server Page created in Step 3 in the InetPub\WWWRoot directory on the IIS Server. 6. 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 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 : kbGrpDSFox Technology : kbVFPsearch kbAudDeveloper kbVFP600 Version : WINDOWS:6.0 Issue type : kbprb Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1999.