Okay, Bitt. You were awesome enough to find that last answer, how about this follow up?

Here's the quote from the HeyScriptingGuy forum I just made. Let's see if you can beat them to the punch... smile

I'm using an HTA (VBScript contained within an HTML Application page) to query WMI at regular intervals for the memory usage of a few key applications.

There are two ways I can do this:
1. Directly querying WMI each time through the loop, creating and destroying a query object each time.
2. Setting up a single Refresher object, which is refreshed each time though the loop, and then getting the values of its members each time though the loop.

The direct query method works great and never fails, but I fear that the constant creation and destruction of the query object might be eating memory.

If I use the "refresher" method, it works fine at first, but then after several minutes, it starts failing: Suddenly it starts returning zeros or nulls for many of its values. Once it does this, the return values are always zero for those processes for a long time. The time period that it takes to start failing can be anywhere from several minutes to half an hour. And here's the kicker: it only fails on Server 2003. On Vista or Windows 7, it works fine without failing.

I have also notice that the two methods, when they're working, return significantly different values despite the fact that I'm querying the exact same values both ways.

Questions:
- Why does the refresher method suddenly fail unexpectedly? (And why only on Server 2003?)
- Why do the two different methods return different values?
- Why does my Direct query method seem to eat memory, despite the fact that I'm setting the object to "Nothing" when I'm done with it? Can anyone help me prevent the direct method from eating memory? I'd give up on the refresher method and just query directly if it weren't for this.

Attached is my example code in VBScript. It must be saved as a .HTA file in order to work. Run it on Server 2003 to see the results (you may have to wait a while).


Attachments
WMITest5.hta (102 downloads)

_________________________
Tony Fabris