473,756 Members | 3,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very high memory usage?

I want to be notified when a PnP device is added or removed. To accomplish
this task, I added two occurrences of a
System.Manageme nt.ManagementEv entWatcher. I've included a snippet of code
that is called when the user pushes a button to start listening. Using the
Windows Task manager I can monitor the CPU usage. When the watchers are
active, the CPU usage spikes to 100%. Turning of the watchers reduces the
CPU usage back to it's quiescent state. Is this expected behavior, or am I
doing something incorrectly? Is there a better way to monitor for PnP
devices being added or removed without incurring this CPU overhead?

TIA

Brad

Code example:
Public Sub StartListen()

Newwatcher = New System.Manageme nt.ManagementEv entWatcher

Newwatcher.Quer y = New System.Manageme nt.EventQuery(" SELECT * FROM
__InstanceCreat ionEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_PnPEntit y'")

AddHandler Newwatcher.Even tArrived, AddressOf NewPlugPlay

Newwatcher.Star t()

Removewatcher = New System.Manageme nt.ManagementEv entWatcher

Removewatcher.Q uery = New System.Manageme nt.EventQuery(" SELECT * FROM
__InstanceDelet ionEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_PnPEntit y'")

AddHandler Removewatcher.E ventArrived, AddressOf RemovedPlugPlay

Removewatcher.S tart()

End Sub
Nov 20 '05 #1
4 3669
Hi Brad,

Based on my understanding, when you enable the ManagementEvent Watcher the
CPU will spike to 100%, it will not reduce until you stop the
ManagementEvent Watcher .

Based on my test, I can not reproduce the problem.
Here goes my test code.

Dim watcher As System.Manageme nt.ManagementEv entWatcher
Public Sub NewPlugPlay(ByV al sender As Object, ByVal e As
EventArrivedEve ntArgs)
MsgBox("New Plug and Play = " +
(CType(e.NewEve nt("TargetInsta nce"), ManagementBaseO bject))("Captio n"))
End Sub
Public Sub StartListen()
watcher = New System.Manageme nt.ManagementEv entWatcher
'
' managementEvent Watcher1
'
watcher.Query = New System.Manageme nt.EventQuery(" SELECT * FROM
__InstanceCreat ionEvent WITHIN 1 WHERE TargetInstance ISA
""Win32_PnPEnti ty""")
AddHandler watcher.EventAr rived, AddressOf NewPlugPlay
watcher.Start()
End Sub
Public Sub StopListen()
watcher.Stop()
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
StartListen()
End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
StopListen()
End Sub

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #2
Peter,

I guess that I'll have to live with CPU usage of 100% while monitoring PnP
device activity. I'm curious about the query:

SELECT * FROM __InstanceCreat ionEvent WITHIN 1 WHERE TargetInstance ISA
""Win32_PnPEnti ty"""

Can you point me to a source that describes how this query, and others like
it, are created? This is not intuitive and I would've struggled without the
MSDN examples.

Thanks

Brad

"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:Eb******** ******@cpmsftng xa07.phx.gbl...
Hi Brad,

Based on my understanding, when you enable the ManagementEvent Watcher the
CPU will spike to 100%, it will not reduce until you stop the
ManagementEvent Watcher .

Based on my test, I can not reproduce the problem.
Here goes my test code.

Dim watcher As System.Manageme nt.ManagementEv entWatcher
Public Sub NewPlugPlay(ByV al sender As Object, ByVal e As
EventArrivedEve ntArgs)
MsgBox("New Plug and Play = " +
(CType(e.NewEve nt("TargetInsta nce"), ManagementBaseO bject))("Captio n"))
End Sub
Public Sub StartListen()
watcher = New System.Manageme nt.ManagementEv entWatcher
'
' managementEvent Watcher1
'
watcher.Query = New System.Manageme nt.EventQuery(" SELECT * FROM
__InstanceCreat ionEvent WITHIN 1 WHERE TargetInstance ISA
""Win32_PnPEnti ty""")
AddHandler watcher.EventAr rived, AddressOf NewPlugPlay
watcher.Start()
End Sub
Public Sub StopListen()
watcher.Stop()
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
StartListen()
End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
StopListen()
End Sub

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #3
Hi Brad,

Thanks for your quickly reply!

Since I can not reproduce the problem, I suggest you try to modify the
query statement as following.
SELECT * FROM __InstanceCreat ionEvent WITHIN 30 WHERE TargetInstance ISA
""Win32_PnPEnti ty"""

You may try to increase the query interval (e.g. change 1 to 30 or larger)
to see if the problem persists.

If you wants to understand WMI, I think the document in SDK is good and
necessary.
Windows Management Instrumentation
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
wmi_start_page. asp
Querying with WQL
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
querying_with_w ql.asp
Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Peter,

Thanks for the pointer to the documentation. I'll start experimenting with
the query interval.

Brad

"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:ZG******** *****@cpmsftngx a07.phx.gbl...
Hi Brad,

Thanks for your quickly reply!

Since I can not reproduce the problem, I suggest you try to modify the
query statement as following.
SELECT * FROM __InstanceCreat ionEvent WITHIN 30 WHERE TargetInstance ISA
""Win32_PnPEnti ty"""

You may try to increase the query interval (e.g. change 1 to 30 or larger)
to see if the problem persists.

If you wants to understand WMI, I think the document in SDK is good and
necessary.
Windows Management Instrumentation
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/ wmi_start_page. asp
Querying with WQL
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/ querying_with_w ql.asp
Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

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

Similar topics

3
4147
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database periodically. What happens, is that the app reads the contents of a text file line by line into an ArrayList. Each element of the ArrayList is a string representing a record from the file. The ArrayList is then processed, and the arraylist goes out of...
2
6941
by: GG | last post by:
Hi, We have a prod server running on SQL server 2000 64 bit. It is a 4cpu server with 16GB of RAM. we have a maxmemory setting of 15.5GB for sql server. Inspite of 15GB being available for sql server, it still uses paging file space, a lot. When looking thru task maanger we can see sql server using 15.5GB of Memory usage and 22GB of Virtual memory usage. I don't understand why it should even be using closer to 7GB of Paging space,...
20
4236
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the memory usage drops to a couple hundred KB. Why? Is there anything I should to to prevent this? I have compiled in release and deactivated all forms of debugging, I think! Thanks, Philip
4
2433
by: Dan K. | last post by:
Hi NG, first of all i am new to OOP and C# so maybe thats my whole problem :) i wrote a small timer application, like i did if i was starting with programming in vb long time ago. the vb application (few years old) has memory usage around 7.000 K ... my new written C# Application around 18.000 K. after few operations like minimize to tray and then reactivate form memory usage rises higher ... i tried to integrate things like...
1
4853
by: Damien | last post by:
Hi guys, I'm looking for ideas for troubleshooting the following. We've tried some random things to try to treat the symptoms, but none seem robust enough to use when we go live, and we'd rather discover the root cause: We've got an ASP.NET application, running on framework 1.1 on Windows 2003 (IIS 6). Under default settings, during testing by two users, we're seeing the CPU usage on w3wp.exe rocket up and stay up (and thus cause web...
0
1086
by: Dinesh | last post by:
Hi, We are seeing high memory usage (1GB) and subsequently out of memory exception. We are trying to transform the documents using xslt and most importantly using Assembly.Evidence to avoid security exception. Is there any known issue with Assembly.Evidence and memory usage. Please help
2
1607
by: Mechul | last post by:
Hi people i need serious help here.. I have a forum and my hosting company suspended it cuz of the high usage of sql. We did everything to make lower the usage but its still high. it was Generated in 2.0792990 seconds (18.30% PHP / 50-80 % MySQL) MySQL Queries:152 / Global Parsing Time: 0.4743950 / Memory Usage: 4.01 MB PHP version: 4.4.4 / Server Load: Bilinmeyen / GZip Compression: Enabled
1
2042
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory...
17
7967
by: Cesar | last post by:
Hello people. I'm having a Winform app that contains a webbrowser control that keeps navigating from one page to another permanentrly to make some tests. The problem I'm having is that after a while, the application is using more than 100 or 150 Mb in RAM, and if I let it continue, it can leave the system without memory. I've been watching in some pages that other people has the same problem with this control when keep navigating for a...
0
9456
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
9273
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,...
0
10032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9841
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,...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.