ata-ul-malik

I have an application that post information (mainly statistics) on wmi. I have a GUI application that get information and displays them. I am facing some issues in Vista (Business):

When I start my program that Get information from wmi, cpu utilization reaches about 50-60% in windows vista. While the usage is about 5-10% on windows xp, and 2003 server. Actually ití»s not my program that is using the cpu, its windows processes named svchost.exe and lsass.exe (when i connect to wmi repository remotely). Is this a known issue, or am I missing something

My program that Get information from wmi uses ManagementObjectSearcher class to Get information. I have two events to which I have registered using ManagementEventWatcher. CPU utilization is high when I connect to wmi remotely.

EDIT: its only when connecting to remote wmi repository. cpu utalization is normal when connecting to local wmi repository.



Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

There a lot of things that can affect start up utilization of your program! Unless your program is failing or you want to do some detailed OS memory and architecture research then it's probably not an issue.






Re: Application Compatibility for Windows Vista WMI issues in Vista

ata-ul-malik

This didnt helped. The problem is that my program refreshes after every 5 seconds. So it gets data from remote repository every 5 seconds. That is the time when CPU utalization is very hight, while its noraml in prvious version of windows. I think its the security of vista that is messing with calls. lsass.exe is responsible for high cpu usage (this process is using high cpu).

Experimentaly, I made a sample appliaction that connect to remote wmi repository to get memory information of that system. This program refreshes every 3 seconds, and is comsuming around 35% of cpu everytime it refreshes. Its the same lsass.exe that is using cpu.

I am putting the code here. If any one can find any potential flaw in the qurey that is responsible for high cpu usage

Code Block

void ShowMemInfo()
{
ManagementScope scope;

ConnectionOptions conOpt = new ConnectionOptions();
conOpt.Username = "administrator";
conOpt.Password = "password";

scope = new ManagementScope("\\\\remoteMachine\\root\\cimv2", conOpt);
scope.Connect();

ManagementObjectSearcher memInfoSearcher = new ManagementObjectSearche (_ncacheConnection, new ObjectQuery("Select CommitLimit, CommittedBytes from Win32_PerfRawData_PerfOS_Memory"));

while (isRunning)
{
try
{
foreach (ManagementObject current in memInfoSearcher.Get())
{
ulong limit = (ulong)current.GetPropertyValue("CommitLimit");
ulong used = (ulong)current.GetPropertyValue("CommittedBytes");

DisplayInfo(limit, used)
}
}
catch{}
Thread.Sleep(3000);
}

memInfoSearcher.Dispose();
}





Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

Are you using Windows Forms at all BTW, having a "dead" catch is a bad idea.






Re: Application Compatibility for Windows Vista WMI issues in Vista

ata-ul-malik

No, the above code is from a console application.



Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

What does the displayinfo function do Or should I say, how do it do it Also, we started with a GUI problem and are now talking about using a console application Please clarify.




Re: Application Compatibility for Windows Vista WMI issues in Vista

ata-ul-malik

The function just display info on console. Nothing else is happening there.

I was telling that on running this console application program the cpu usage reaches around 35% in vista on every refresh (after 3 seconds). Lets just take the above example and find the solution. There is nothing wrong with my GUI program as, I already mentioned, cpu usage is around 5-10% in earlier versions of windows.

Its the process lsass.exe thats taking the high amount of cpu. And it only happens when getting data from remote repository. My thinking is that its vista securtiy thats messing with the calls.

Any suggestions





Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

I'm still confused. You say you your "GUI" program but yet your talking about console program Which is it Does it actually have UI or not I wasn't able to repro you issue with a code fragment you sent. You might consider using a hidden form and a timer at a way to do this instead of with a separate thread. What is this program used for






Re: Application Compatibility for Windows Vista WMI issues in Vista

ata-ul-malik

Let me explain again.
I have a GUI program. This application refreshes every 5 seconds (configurable by user). I have a provider which post data to wmi repository. The GUI application is used to get that data (either from local respository or remote repository). Now I have been running that program on windows xp and 2003 without any problem. Then I tried it in windows vista. I observer that cpu usage reaches at about 50% whenever my program refreshes (try to fetch information from wmi). This high cpu usage is observed whenever I am connected to remote repository. Its not my application that is using cpu, its lsass.exe and svchost.exe that are using cpu.

Now I copied the above code from that application and used it in console appliation. My actual application makes around 7-8 queries on every refresh, i just copied on query and tried to see its impact. When I ran my application, the cpu usage shoots to 30% every 3 seconds.
The same lsass.exe and svchost were using cpu, not my console application.

I think I made it clear now: that console application just contains 1 query that I have copied from my application.
I can send you screenshot of resource monitor if you will. I am always able to reproduce it

Thanks for you patience.




Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

Ok, so this sounds like a performance issue. You connect to a remote repository using WMI and you experience an abnormally high CPU utilization.

Are you running this as an administrator I see you have a user name and password hard coded into your program is that correct Is your program manifested There might be some permission management tasks going on so that's the only thing I can think of that might "speed" up the process. Otherwise you may have run into a perf issue that should be escalated to the core team if you are a partner.






Re: Application Compatibility for Windows Vista WMI issues in Vista

ata-ul-malik

Yes this is a performance issue, and thas only in vista.
I have chaned user name and password while posting this program, but I am running this as administrator in my program.
And the assembly is not menifested.




Re: Application Compatibility for Windows Vista WMI issues in Vista

Bruce N. Baker - MSFT

BTW, having a hardcoded name password pair is not the a recommended security procedure :-) I'd definately look into reading the application compatibility cookbook as well.

Does your program just hang while it's waiting for the WMI call to get back to it Is there a reason you need to get the data that often

The bottom line is that I don't know of a mitigation to your issue.

I'd be curious to know if the time was different if UAC wasn't temporarily turned off.

BTW, how is "isrunning" reset to false And is there a reason you aren't not handling error properly and just throwing it them away instead