1

We have a web application based on asp.net 1.1. We deployed it on a web server but there is a problem about it. In the webserver sometimes cpu usage is increasing to 100% and outofmemory exception is occuring.

I think there are some wrong code inside the project but i don't know where it's.

Now, i want hear your advices about how to find problem and what kind of codes make cpu usage increased.

mavera
  • 3,171
  • 7
  • 45
  • 58
  • 1
    Are you serious with this question? There are exactly infinity possible cases for an increased CPU usage. So at your place I would start by describing exactly what this application is doing, how it is coded, ... Of course the more details your provide the more probable is to get good answers. – Darin Dimitrov Nov 27 '10 at 09:22
  • May be you are right. But there is something interesting i have seen in the server. Before system throw the OOM exception, CPU usage became 100%, an event log with id 1078 is occured in the event view and w3wp.exe uses 1200 k memory. – mavera Nov 27 '10 at 09:28
  • @mavera, this doesn't help at all. What was the application doing when you saw the increased CPU usage? Accessing a database, parsing some XML file, calculating PI with an infinite precision, launching missiles, ...? – Darin Dimitrov Nov 27 '10 at 09:28
  • @Darin, thanks for response. In application, there are hounders of page and there are almost 2000 customers use it. So i couldn't find which page or process cause this problem. I want to hear your advices about finding the cause, not the solution. – mavera Nov 27 '10 at 09:42
  • 1
    @mavera, when an exception is thrown it usually comes with a stack trace which might help you pinpoint the location/method where this exception originated in your code. Once you've determined it you will know what is the method doing. – Darin Dimitrov Nov 27 '10 at 09:48
  • Thanks @Darin. I'll check that and I hope i will find the problem. – mavera Nov 27 '10 at 10:02

2 Answers2

0

it looks like the garbage collector is not doing its work as supposed for some reason. i suggest to look in the code where you have variable declarations inside long loops. for example you need to check for loops that look like this:

dim c as car
for i as integer = 0 to 20
    c= new car
    c.brand=""
Next

the above loop creates a lot of garbage so make sure to call dispose() when you finish using an object.

another issue to check for is recursion. if you have recursive calls, make sure to check that the breaking condition is correct and make sure to call dispose() too before jumping in the next recursion.

Ali Tarhini
  • 5,278
  • 6
  • 41
  • 66
  • I'm sorry to say that this answer is in no way helpful. Out of memory exceptions don't necessarily indicate that the GC isn't working, and searching for recursive calls is a waste of time. Rather than taking guesses, the first thing you should do is profile the error. – OJ. Nov 27 '10 at 11:57
  • i did not say that GC is not working, i said that its not working as it should because of a bad programming practice which is likely to be the cause of the error. and this is the first thing to look at in the code which could save a lot of time doing the profiling. – Ali Tarhini Nov 27 '10 at 12:01
  • Rubbish. Profiling the error and debugging it hands down beats randomly scanning the code and guessing. Profiling a dump of the issue will easily point you at the error. You just have to make a bit of effort. Also, down-voting my answer because I down-voted yours is absolutely pathetic. – OJ. Nov 27 '10 at 12:30
  • having a different point of view does not mean that my approach is rubbish. please correct your words. It also doesnt imply that your correct. By the way, its not me who gave you the down-vote. – Ali Tarhini Nov 27 '10 at 12:36
-1

If you have no idea how to debug something once it's deployed, the first place you should look to learn is Tess Ferrandez's blog. Click, and read. A lot. :) May I suggest you start with the debugging labs.

OJ.
  • 28,944
  • 5
  • 56
  • 71