PRB: Memory Not Released Using Implicit Assignment With VBScriptID: Q192551
|
When running an application in Internet Explorer that mixes VBScript and JScript, memory consumption and time to execute increase. Memory is not reclaimed until the page is refreshed or the browser closed.
When variables are assigned implicitly and then reassigned (as in a loop), separate copies of the variables appear to be made with each reassignment. Memory allocated to these variables is not reclaimed until the document is closed.
Variables in VBScript should be explicitly declared using the Dim statement.
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
<HTML>
<HEAD>
<SCRIPT Language="VBScript">
Sub Button1_OnClick()
For j = 0 to 10000
t = "Now "
s = t + "is " + "the " + "time "
k = s + "for all good men."
Next
DisplayVB.innerHTML = "<B>" + k + "</B>"
End Sub
</SCRIPT>
<SCRIPT LANGUAGE="JScript">
function button2OnClick()
{
for ( i = 0; i < 10000; ++i ) {
t = "Now ";
s = t + "is " + "the " + "time ";
k = s + "for all good men.";
}
DisplayJS.innerHTML = "<B>" + k + "</B>";
}
</SCRIPT>
</HEAD>
<BODY BGColor="#FFFFF0">
<font face="arial">
<INPUT TYPE="Button" NAME="Button2" VALUE="Run JScript"
onClick="button2OnClick()" style="width:100;">
<BR><BR>
<SPAN ID=DisplayJS></SPAN>
<BR><BR>
<INPUT TYPE="Button" NAME="Button1" VALUE="Run VBScript"
style="width:100;">
<BR><BR>
<SPAN ID=DisplayVB></SPAN>
<BR><BR>
</BODY>
</HTML>
<SCRIPT Language="VBScript">
Sub Button1_OnClick()
Dim j, t, s, k
For j = 0 to 10000
t = "Now "
s = t + "is " + "the " + "time "
k = s + "for all good men."
Next
DisplayVB.innerHTML = "<B>" + k + "</B>"
End Sub
</SCRIPT>
Perform the steps above and note that memory consumption does not increase.
For more information, please see the MSDN Web Workshop:
http://msdn.microsoft.com/workshop/default.asp
http://msdn.microsoft.com/scripting/
Additional query words: VBScript JScript Memory Usage
Keywords : kbIE kbIE400 kbIE401 kbJScript kbScript kbIE401sp1 kbIE500
Version : WINDOWS:3.0,4.0,4.01,4.01sp1
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 30, 1999