homepage Welcome to WebmasterWorld Guest from 54.237.184.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
re-use of ActiveX-object Msxml2.XMLHttp.6.0 failing
DoppyNL




msg:3461159
 7:50 am on Sep 26, 2007 (gmt 0)

See the following code:


var Browser = window.appname;
var HTTPRequestObjectCounter = 0;
var HTTPRequestObjectPool = new Array();
function HTTPRequestObject()
{
HTTPRequestObjectCounter++;
Log('HTTPRequestObject: ' + HTTPRequestObjectCounter);
while (HTTPRequestObjectPool.length < 20)
{
try
{
Handle = new ActiveXObject('Msxml2.XMLHttp.6.0');
}
catch (E)
{
try
{
Handle = new ActiveXObject('Msxml2.XMLHttp.3.0');
}
catch (E)
{
try
{
Handle = new XMLHttpRequest();
}
catch (E)
{
//
}
}
}
HTTPRequestObjectPool.push(Handle);
Handle = null;
}
return(HTTPRequestObjectPool.shift());;
}
// variables
var ServercheckRunning = false;
var ServercheckNexttime = CurrentStampLocal() + 15000;
var ServercheckTimeoutHandle = null;
var ServercheckURI = null;
var ServercheckHandle = null;
var ServercheckResponse = null;
var ServercheckPointer = null;
//
// function
function Servercheck()
{
// Set flag "Running"
ServercheckRunning = true;
//
// Set timeout
ServercheckTimeoutHandle = setTimeout('ServercheckTimeout();', ServerTimeout);
//
// determine URI
ServercheckURI = ServerURI + 'servercheck.php?CurrentStampLocal=' + CurrentStampLocalString();
//
// send request
ServercheckHandle = HTTPRequestObject();
ServercheckHandle.onreadystatechange = ServercheckStatechange;
ServercheckHandle.open('POST', ServercheckURI, true);
ServercheckHandle.send();
//
}

function ServercheckStatechange()
{
if (ServercheckRunning == true)
{
if ((ServercheckHandle.readyState == 4) (ServercheckHandle.readyState == 'complete'))
{
if (ServercheckHandle.status == 200)
{
// handle response
// code removed
// handle response
}
// call done
ServercheckDone();
//
}
}
}
function ServercheckDone()
{
// clear timeout
clearTimeout(ServercheckTimeoutHandle);
//
// cleanup
ServercheckURI = null;
ServercheckResponse = null;
ServercheckPointer = null;
//
// HTTPRequestObjectPool
HTTPRequestObjectPool.push(ServercheckHandle);
delete ServercheckHandle;
//
// set next moment
ServercheckNexttime = (CurrentStampLocal() + (60 * 1000 * ServercheckInterval));
//
// clear flag "Running"
ServercheckRunning = false;
//
}
function ServercheckTimeout()
{
// abort
ServercheckHandle.abort();
//
// call done
ServercheckDone();
//
}
//

The script fails after some time with the following error message:
"Object doesn't support this property or method."
The line where this occurs is a line wich has a "send()" method on it.

I put the counter in place to find out when exactly it fails. This is not at number 21, but at a random higher number. But under the 100.

I know that both version 6 and 3 are available on the system.
When I leave version 6 out of the code, it will still fail but it won't give me an error message. Requests made to the server won't be executed.

I refill the list to 20 objects initially just to see what happens. I've got better code that doesn't do this and only creates 1 object when none are available.

When I create a new object each time I use it, the system will start to become slow overtime and eventually crash.

Am I not "closing" the first requests as I should? How should that be done?
What am I doing wrong?

 

DoppyNL




msg:3461488
 2:37 pm on Sep 26, 2007 (gmt 0)

A sympton wich I think may be related to the above problem is the following:

Memory usage increases at some point; direct cause of this can't be determined exactly. Task Manager shows that it is Internet Explorer itself who is responsible for this.
When the memory usage increases, the computer also becomes slower. Movies are displayed slower (by windows media player) and other things that is done by javascript is going slower.

When the system hangs, memory usage by Internet Explorer is also high.

When 1 Internet Explorer window is closed (where all the action happens in), memory usage will drop a bit, but not to a normal level.
When the second Internet Explorer window is closed (the last one and wich is also allways open. This one is only used on "startup") memory usage returns to normal.

DoppyNL




msg:3467823
 10:29 am on Oct 3, 2007 (gmt 0)

Apperently this is a very though question as nobody has yet even replied.

Suggestions on what may be helping are also welcome. I don't need a ready-to-use-fix, as long as I can get the code fixed in the end I'm happy.

If you've got suggestions on how do a request to the server in a different manner that is also welcome.
Using an entirely different method may also solve the problem.

Thanx!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved