473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CPU usage is high, can I know what is hogging the CPU?

In short, is there any way to know the very code that is currently
hogging the CPU?

I've written an application which continously GETting web pages using
HttpWebRequest' s asynchronous methods (it only GETs responses
(BegingGetRespo nse,EndGetRespo nse), not reads the stream contents).
I've read articles about asynchronous request operations. I aborted
timed out requests based on the article. ( http://www.developerfusion.co.uk/show/4654/
) And, I kept the number of HttpWebRequets waiting for response below
30. But still, as the execution time passes, the CPU usage is
gradually increasing. If memory consumption gets gradually high, then
I might think it's due to some memory leak, but what about this
situation? At first the CPU usage was below 5% but about 6 minutes
later, it gets as high as 40%. I don't know why it increases when it
is doing the same work in a loop.

I've downloaded the CLR profiler from Microsft and tried it, but it
only showed memory usages and allocations, not the CPU usage. When my
application is hogging 40% of the CPU, is it possible for me to know
which operation is consuming it? Since my code is simple, I think it
is probably one of the underlying HttpWebRequest or other BCL classes.

Thanks for your help.
Dec 11 '07 #1
2 2326
Sin Jeong-hun,

Well, you kind of indicated what the problem might be. You said that
you are running the work in a loop. This is a CPU-bound operation, and is
going to consume the CPU depending on what you are doing in the loop and how
many iterations you are performing.

What exactly are you doing in the loop?

Also, how are you determining what your memory consumption is?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sin Jeong-hun" <ty*******@gmai l.comwrote in message
news:5a******** *************** ***********@s19 g2000prg.google groups.com...
In short, is there any way to know the very code that is currently
hogging the CPU?

I've written an application which continously GETting web pages using
HttpWebRequest' s asynchronous methods (it only GETs responses
(BegingGetRespo nse,EndGetRespo nse), not reads the stream contents).
I've read articles about asynchronous request operations. I aborted
timed out requests based on the article. (
http://www.developerfusion.co.uk/show/4654/
) And, I kept the number of HttpWebRequets waiting for response below
30. But still, as the execution time passes, the CPU usage is
gradually increasing. If memory consumption gets gradually high, then
I might think it's due to some memory leak, but what about this
situation? At first the CPU usage was below 5% but about 6 minutes
later, it gets as high as 40%. I don't know why it increases when it
is doing the same work in a loop.

I've downloaded the CLR profiler from Microsft and tried it, but it
only showed memory usages and allocations, not the CPU usage. When my
application is hogging 40% of the CPU, is it possible for me to know
which operation is consuming it? Since my code is simple, I think it
is probably one of the underlying HttpWebRequest or other BCL classes.

Thanks for your help.

Dec 11 '07 #2
Instead of doing your work in a loop, use a Threadpool with QueueUserWorkIt em
and a callback method. Make sure that you Close / Dispose of any Response
streams in a finally block in the callback.
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Sin Jeong-hun" wrote:
In short, is there any way to know the very code that is currently
hogging the CPU?

I've written an application which continously GETting web pages using
HttpWebRequest' s asynchronous methods (it only GETs responses
(BegingGetRespo nse,EndGetRespo nse), not reads the stream contents).
I've read articles about asynchronous request operations. I aborted
timed out requests based on the article. ( http://www.developerfusion.co.uk/show/4654/
) And, I kept the number of HttpWebRequets waiting for response below
30. But still, as the execution time passes, the CPU usage is
gradually increasing. If memory consumption gets gradually high, then
I might think it's due to some memory leak, but what about this
situation? At first the CPU usage was below 5% but about 6 minutes
later, it gets as high as 40%. I don't know why it increases when it
is doing the same work in a loop.

I've downloaded the CLR profiler from Microsft and tried it, but it
only showed memory usages and allocations, not the CPU usage. When my
application is hogging 40% of the CPU, is it possible for me to know
which operation is consuming it? Since my code is simple, I think it
is probably one of the underlying HttpWebRequest or other BCL classes.

Thanks for your help.
Dec 12 '07 #3

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

Similar topics

3
4127
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...
3
2832
by: Evan Smith | last post by:
Scenario: new functionality was recently deployed in a 3-tier business application. Since deployment, CPU use has shot up to very high levels. Using event monitors to try to track down the culprits hasn't fingered any bad query in particular who's hogging CPU. One interesting anomaly is that there is a single type of query that averages 70...
5
2479
by: Manish Jain | last post by:
Environment: Windows 2000 Server (SP4), ASP.Net/C# (Framework 1.1) Hardware: PIII @ 700 MHz, 512 MB RAM ---------------------------------------------------------------------------- ------------------------------------------------------- I have developed a web application which I am deploying on above mentioned environment. Problem is that...
10
2331
by: Niall | last post by:
I'm not quite sure which groups to post this to, so short of a massive crosspost, I decided on these two. I am running into troubles with resource usage of our app on Win2k and above systems. In several places, I have seen it said that the WinNT model only limits resources to available memory. However, I have seen errors caused by running...
7
2307
by: Marco Martin | last post by:
Hi Group, I've been working on an application that reads data from a comm port and 1) writes the data to file, 2) displays this data in three different graphs in real time.The port is receiving data at 38400 baud, the plan is that it will go up to 115k baud. My app works fine on my development pc (P4 2.6G), But when the application runs on...
1
4834
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...
0
2080
by: Learning.Net | last post by:
I have a window application that uses ActiveX browser component for testing web site automatically using mshtml. Though application is running fine but there is abnormally high page file usage. The Maximum PF Usage often rising as high as 2 GB. How to reduce this page file usage & reasons behind this high page file usage? Anyone can help...
1
2033
by: santhescript01 | last post by:
I have a window application that uses ActiveX browser component for testing web site automatically using mshtml. Though application is running fine but there is abnormally high page file usage. The Maximum PF Usage often rising as high as 2 GB. How to reduce this page file usage & reasons behind this high page file usage? Anyone can help me...
1
1055
by: tc | last post by:
Hi, does anyone how how I might check on the memory usage of a running application? I want to do this externally to the 'actual' application that I've written, so a small stand alone app that can keep a check on another? Basically the application in question hangs after a week or so of continual use and I need to prove if it my application...
0
7695
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...
0
7922
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. ...
1
5509
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...
0
5218
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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...

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.