Groups | Blog | Home
all groups > asp.net webservices > september 2004 >

asp.net webservices : Memory leak in IE javascript with webservice.htc



cmbardon NO[at]SPAM engmail.uwaterloo.ca
9/27/2004 12:11:26 PM
I'm working on an application where I need to be able to call a .net
web service from javascript. I found the webservice.htc file, and was
able to create a page that worked just fine, except that the memory
usage of iexplore.exe began to increase without limit as the service
was called. To demonstrate this, I tried the following script, which
showed the increase very quickly by continuously calling the service.
Since useService is the only method being called, this is likely where
the problem lies. Is there a fix for this problem yet?

Thanks,

Chris


<html>
<head>
<script language="JavaScript">

function init()
{
service.useService("http://testServer/testcti/service1.asmx?WSDL","Test");
call();
}

function call()
{
service.TestCTI.callService("AgentEventWait",1000,100,"ice1");
}

function onWSresult()
{
call();
}
</script>
</head>
<body onload="init()">
<div id="service" style="behavior:url(webservice.htc)"
onresult="onWSresult()">
</div>
</body>
bruce barker
9/27/2004 12:59:19 PM
IE has lots of memory leaks, not surprising that that there is a leak
calling xmlhttp. I doubt that any fix will be coming, as the soap behavior
calls for increased security settings with xp-sp2. switch to the standard
hidden frame approach for IE, and save soap calls for mozilla/netscape which
have it in.

-- bruce (sqlwork.com)


[quoted text, click to view]

Gabe Garza
9/27/2004 9:09:20 PM
Chris,

You've setup call() to call itself until run IE runs out of memory.
'onresult' is for checking the result of a callService().
In your 'onWSresult()' Javascript function don't call call(), check for the
following

function onWSresult()
{
if((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;

// Add code to output error information here
alert("Error ");
}
}

The way you have it now

function onWSresult()
{
call();
}

onWSresult() calls call() over and over again because you've setup a
onresult to fire an event after AgentEventWait is finished.

Once the first call() is finished, which is your call to your
AgentEventWait, that's when your onresult event gets fired, which is your
onWSresult() function.
onWSresult() calls call() again, once that call is finished, again your
AgentEventWait, then that's when your onresult event gets fired again, which
is your onWSresult().

To verify that this is the case, use DbgCLR.exe and set a breakpoint inside
of AgentEventWait, then call your HTML page that calls the webservice.
You'll see AgentEventWait being called again and again.

Gabe


[quoted text, click to view]

Gabe Garza
9/27/2004 9:20:05 PM
Opps, meant to say until the OS runs out of memory.

[quoted text, click to view]

cmbardon NO[at]SPAM engmail.uwaterloo.ca
9/28/2004 5:00:59 AM
Thanks Bruce-is there somewhere that details this "hidden frame"
approach that you're talking about? I tried a version where I had a
frame invoking the web service using an HTTP GET call and the page's
location property, but there was no way that I could get the returned
XML to the main frame without an access violaton. Since the web
service call that I'm making can block, I can't really use the auto
refresh property to perpetually call it. Ideally, I'd like to be able
to do what I had in my script, which is to call the service, handle
the return, then call it again. Any idea how I can accomplish this?

[quoted text, click to view]
AddThis Social Bookmark Button