473,772 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handle Leaks with Microsoft.XMLDO M

I have a problem where the below code chunk causes handle leaks on some
machines. The leak APPEARS to be handles to the registry key:

HKCU\Software\M icrosoft\Window s\CurrentVersio n\Internet
Settings\ZoneMa p

The below code runs on a timer running several times per second and
after about 15-30 minutes or so, it runs out of handles and crashes IE.

I found an article on msdn discussing how setting properties in this
way could cause memory leaks if the reference to the nodeValue in the
div isn't set to null before leaving the page (they suggest doing this
in an unload function though of course, that does not quite work here
since we aren't unloading... we're just constantly updating the data).

Instead, as you can see below, I've set the div's innerHTML to null
prior to resetting it.... to no avail. Any help would be much
appreciated.

--Mike

var currentId;
var responseXML;
var xmlDoc;

var xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
xmlhttp.open("P OST", "<URL>" //where <URL> is the url that is
responding with xml data
xmlhttp.onready statechange=fun ction()
{
if (xmlhttp.readyS tate==4)
{
responseXML = xmlhttp.respons eText;
xmlDoc = new ActiveXObject(" Microsoft.XMLDO M");
xmlDoc.loadXML( responseXML);

for (i=0; i<xmlDoc.docume ntElement.attri butes.length;
i++)
{
currentId =
xmlDoc.document Element.attribu tes[i].nodeName;

document.getEle mentById(curren tId).innerHTML =
null;
document.getEle mentById(curren tId).innerHTML =
xmlDoc.document Element.attribu tes[i].nodeValue; //Note:
Commenting out this line removes the handle leak.... but of course that
also prevents my data from updating.
}
delete xmlDoc;
xmlDoc = null;
responseXML = null;
}

xmlhttp.send(nu ll);
delete xmlhttp;
xmlhttp = null;

Nov 23 '05
39 7438
JRS: In article <11************ **********@g44g 2000cwa.googleg roups.com>
, dated Mon, 28 Nov 2005 09:38:59, seen in news:comp.lang. javascript, VK
<sc**********@y ahoo.com> posted :

// IE doesn't operate with the real time but with
// system ticks - 60ms per tick
// so setTimeout(..., 0,10,25,59) all means 60


Misleadingly inaccurate.

In Win98, IE4 uses ticks at about 54.9 ms intervals, and new Date() has
a resolution of 10 ms.

The interval and resolution depend on the OS/browser combination, I've
been told that IE on Mac OS X gives 1 ms for both.

AISB, read the newsgroup FAQ; see below.

More results for/from
<URL:http://www.merlyn.demo n.co.uk/js-dates.htm#Ress>
would be appreciated.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 29 '05 #11
Dr John Stockton said the following on 11/29/2005 3:07 PM:

<snip>
More results for/from
<URL:http://www.merlyn.demo n.co.uk/js-dates.htm#Ress>
would be appreciated.


IE6 on Win XP SP2 gives me 15.6/15.7 for Update Interval. It alternates
between the two for the most part. Numerical Resolution of 1.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Nov 29 '05 #12
ty*****@gmail.c om wrote:
I have a problem where the below code chunk causes handle leaks on some
machines. The leak APPEARS to be handles to the registry key:

HKCU\Software\M icrosoft\Window s\CurrentVersio n\Internet
Settings\ZoneMa p
Have you tried making -- xmlDoc = new
ActiveXObject(" Microsoft.XMLDO M"); -- a static variable instead of
creating it each time?

Is there any security involved as far as accessing the server?
The below code runs on a timer running several times per second and
after about 15-30 minutes or so, it runs out of handles and crashes IE.


Is it possible that the webserver is running out of connections?
That'll mess up xmlhttp sometimes.

Also, be aware that in some IE 6's, if you use onUnload you sometimes
have to also call abort() on xmlhttp to clear things up correctly. (I
know this isn't your case, though.)

Another suggestion is to not only make the xmlDoc a static, but avoid
using your "responseXM L" as an intermediary variable. Perhaps directly
use:

xmlDoc.loadXML( xmlhttp.respons eText)

And instead of creating a function each time for the
xmlhttp.onready statechange, just point to a static one.

Just some ideas,
Kev

Nov 30 '05 #13
rf
Dr John Stockton wrote:
JRS: In article <11************ **********@g44g 2000cwa.googleg roups.com>
, dated Mon, 28 Nov 2005 09:38:59, seen in news:comp.lang. javascript, VK
<sc**********@y ahoo.com> posted :

// IE doesn't operate with the real time but with
// system ticks - 60ms per tick
// so setTimeout(..., 0,10,25,59) all means 60

Misleadingly inaccurate.

In Win98, IE4 uses ticks at about 54.9 ms intervals, and new Date() has
a resolution of 10 ms.

The interval and resolution depend on the OS/browser combination,


Not inaccurate, merely misleading.

The timer tick interval depends on the OS and has nothing to do with the
browser.

The win9x family of operating systems use an interval of 54 odd ms. The NT
family differ. I cannot recall what NT3.x and NT4 use but NT5 (2000) and
NT5.1 (XP) use 15 odd ms although some have been reported to use 10 odd ms.
Windows server 2003 uses 100ms or 200ms, can't remember which.

The resolution of any function that access the system clock (which is
updated at timer tick) would be exactly the same as the timer tick. There
is, after all, only one clock.

There are low level API functions which will change the timer tick interval
as a side effect but these functions would rarely be used by a normal
application like a browser as they are not aimed at time but rather
performance in near real time multithreaded applications.
I've
been told that IE on Mac OS X gives 1 ms for both.


The documentation that details the above low level functions (microsoft of
course) warns that causing the timer tick to drop below 2ms can have
disasterous results on system performance. Perhaps Mac OS X uses a
different architecture to maintain the system clock.

--
Cheers, Richard.
Nov 30 '05 #14
rf wrote:
<snip>
The resolution of any function that access the system clock
(which is updated at timer tick) would be exactly the same
as the timer tick. There is, after all, only one clock.

<snip>

I am not sure that you can go that far. The resolution of a function
that accesses the system clock can be no better than the OS tick, but it
could be worse.

Richard.
Nov 30 '05 #15
VK

Dr John Stockton wrote:
VK <sc**********@y ahoo.com> posted :
// IE doesn't operate with the real time but with
// system ticks - 60ms per tick
// so setTimeout(..., 0,10,25,59) all means 60


Misleadingly inaccurate.

In Win98, IE4 uses ticks at about 54.9 ms intervals, and new Date() has
a resolution of 10 ms.


As I like to say: "Do not mix a God's gift with a omlet" (means "to do
not think the same on two totally diffrent things").

When you run a separate application it can be only as accurate as the
system tick of the particular OS (50ms? on Win98 -... - 10ms? on
Linux).

If you want a better accuracy (say bor benchmarking) you have to
program a low-level hardware access to the system clock.

When you run a JavaScript program it can be only as accurate as the
system tick set for the host application which is Internet Explorer in
our case.

Nevertheless the system usually keeps you out of this timing "misery",
so say in Java you even can use nanoseconds and still get some
true-looking results. It achieved by calculating the average interval
by formula ms = (system tick)*(n of ticks) + (lower byte spice)

This explain some fantastic system ticks like 54.9 ms ;-) I assure you
that no system runs on such periods.

More useful reading (besides OS specs) :
<http://msdn.microsoft. com/workshop/author/dhtml/reference/properties/truespeed.asp>

Nov 30 '05 #16
I just posted this comment to
microsoft.publi c.windows.inete xplorer.ie6.bro wser and it should go here
as well.
I have a problem where the below code chunk causes handle leaks on some
machines. The leak APPEARS to be handles to the registry key:

HKCU\Software\M icrosoft\Window s\CurrentVersio n\Internet
Settings\ZoneMa p


Hi,
I'm just fighting exactly the same problem, but I don't think that this
is only related to XMLHTTP. I have latest WindowsXP (SP2+windowsupd ate,
IE version 6.0.2900.2180.x psp_sp2_gdr.050 301-1519). My IE seems to open
new handles each time I :

.. set src on SCRIPT element (2 handles)
.. set src on IFRAME element (2 handles)
.. set src on IMG elment (2 handles)
.. set innerHTML propery to some text (=no new elements) on DIV (or any
other visual element) (2 handles)

IE starts with 12 handles (having about:blank as homepage), then it
takes randomly another 2 or 4 handles each time I load the age/press
F5. This appears even if the page loaded is a 403 for instance. It's
not related to user auth scheme (I found this problem in out
application which is using NTML but it's the same even for anonymous
access). It's not related to membership of the server in zones - it
does the same when I put the server into "trusted" and when it's not
there. I've created small test page which allows you to test the
actions I mentioned (http://linda.cooper.cz/awe/test/ie/).

When the number of opened handles reaches 64k IE partly stops working,
if you had a server in "trusted" zone it starts to recognize it as
"internet" etc.

I'm going to test that on clean WindowsXP and then after each
servicepack/IE update to find the one which caused this problem but
this will take some time. Another clue might be that this behavior
can't be reproduced on Windows 2000 (SP4+windowsupd ate).

Feel free to contact me if you need to clarify things/get additional
information.

With regards,
Martin

Nov 30 '05 #17
JRS: In article <pJ************ *************** ***@comcast.com >, dated
Tue, 29 Nov 2005 18:40:50 local, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
Dr John Stockton said the following on 11/29/2005 3:07 PM:

<snip>
More results for/from
<URL:http://www.merlyn.demo n.co.uk/js-dates.htm#Ress>
would be appreciated.


IE6 on Win XP SP2 gives me 15.6/15.7 for Update Interval. It alternates
between the two for the most part. Numerical Resolution of 1.


Thank you; entered. If you increase Loop Count to 100 you should get
15.62/15.63; to 1000, 15.625, if not interrupted.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Nov 30 '05 #18
t's strange to reply to one's own post, but - the problem is caused by
hotfix 896688, the only trouble is that it fixes quite a holes in
security :(

Nov 30 '05 #19
JRS: In article <dm************ *******@news.de mon.co.uk>, dated Wed, 30
Nov 2005 01:27:40 local, seen in news:comp.lang. javascript, Richard
Cornford <Ri*****@litote s.demon.co.uk> posted :
rf wrote:
<snip>
The resolution of any function that access the system clock
(which is updated at timer tick) would be exactly the same
as the timer tick. There is, after all, only one clock.

<snip>

I am not sure that you can go that far. The resolution of a function
that accesses the system clock can be no better than the OS tick, but it
could be worse.


A browser writer *could* go further.

In the PC architecture, the 54.9 ms clock is obtained by division by
65536, and the signal that drives that can be divided by other numbers.
Signals of much higher frequency can be read in Win98/PII and higher -
there's the RDTSC instruction, and the performance counter.

Additionally, there's the PC RTC, driven by a 32 kHz crystal, which
could be used.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Nov 30 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1132
by: Saravanan D | last post by:
Hello, I have python module which uses C++ extension modules. If I run the Python Module for a long time in an windows environment, Perfmon shows handle leaks in Python.exe. Is there any way to detect it ? Thanks in Advance. Saravanan D
3
1524
by: Ray | last post by:
Hi, Al There is a xml file, I want to read/write it in ASP. As following source code, dim objXm Set objXML = Server.CreateObject("Microsoft.XMLDOM" objXML.async = Fals objXML.load server.mappath("../online.xml" If objXML.parseError.errorCode <> 0 The response.write "parse online.xml error(" & xsl & ") response.en End I
2
1989
by: jfizer | last post by:
I have a web app that uses a form with its fields populated from XML using Microsoft.XMLDOM. The problem is that Microsoft.XMLDOM functions seem to run on their own thread, so I dont know when the fields are done populating. Can anyone think of a way for me to check when the following function finishes? function importXML(xmlQuery,xmlSrc,xmlTarget) {
0
3907
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from dllmodul.cpp(102) similar to what is mentioned below)... I am calling MFC as part of unmanaged code used by the managed code. +--------
7
1824
by: Ken Varn | last post by:
I am working in managed C++. I have a Mutex object in which I need to replace the Handle property with a new handle. The new handle is being constructed using Win32 CreateMutex call. I need to call the Win32 version in order to set the security descriptor for the mutex, which is not natively supported in .NET Framework 1.1. I always get a little nervous about resource leaks when trying to bridge Win32 with .NET, so I want to make sure...
0
2068
by: =?Utf-8?B?TWF0dCBDYWxob29u?= | last post by:
HI there, I am getting an error on my page which calls up a web service. Microsoft VBScript runtime error '800a13ba' Unknown runtime error: 'SearchQueryXML' /SearchResults.asp, line 142
2
35622
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the implementation so the two can vary independently. Handle classes usually contain a pointer to the object implementation. The Handle object is used rather than the implemented object. This leaves the implemented object free to change without affecting...
1
6764
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I have a vb.net program that leaks handles as reported by task manager. After running for a couple of hours, task manager reports over 1000 handles, and it continues to grow. I think I am failing to close or dispose something. I've looked at the code and can't spot the problem. The program is fairly big (10k lines). I can ask it to do something that always increases the handle count, so the problem is reproducible. What I don't know...
1
4226
AnuSumesh
by: AnuSumesh | last post by:
Hi, I want to read the text property of XML file. My xml file is as follows: <?xml version="1.0"?> <Domain_Credentials> <User> anu </User>
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.