Link to home
Start Free TrialLog in
Avatar of ko78
ko78

asked on

dllhost.exe taking 100 Percent CPU Utilization

Experts,
I have a big problem, We have developed a web application that is running on Windows 2000 server SP4, and IIS 5. Every now and then the application goes down, the browser keeps on calling the page with no response. The web server administrator informed us that the application which is running in an isolated dllhost.exe is taking 100% cpu usage. When we inspected the IIS logs we found the following ASP_0147|Internal server error in the logs. The problem is solved by running iisreset or just by stopping and restarting the Com Application from the component services, Please note that the only logs availabe in the IIS logs we can not deploy any debugging tools on the server :(
I can post a piece of code that shows what we do if you want

Help is greatly appreciated.
Avatar of ko78
ko78

ASKER

Sorry about that :)
It's not an exe it's a web application, Written in ASP

Thanks
The can only suggest a scenario that causes this type of behaviour - infinite loops, more often a nested loop (do..loop), typically the inner loop goes around and around and around - you get the idea - left long enough it will bring the server to a grinding stand still.
Avatar of fritz_the_blank
Most often, it is because you are iterating through a recordset, and you forget to use the .MoveNext() on the recordset. That will result in the infinite loop and the gobbling of resources.

Fritz the Blank
:(

Damb - forgot to mention that bit.
There are some more factors that could cause the same problem.
String Concatenations. If you perform large string concatenations, the CPU goes for a toss and mostly you will have to end up restarting the IIS.

Another thing would be the fact that you have not destroyed all the objects created. Especially if you create objects in a loop and doesnt destroy them by setting them to nothing.

Another important consideration would be the threading model of the DLL. Make sure the component is not apartment threaded and that you havent created the object with session /application scope.

Cheers!!
Avatar of ko78

ASKER

Lord_McFly & fritz_the_blank
I have no loops at all in the page :( I wish I had, all what the page do is checking for the user priviliges from the database and show the links he should use, these links are considered the entry points to the application.

e.g.
AuthorizedToCreate      = CanCreateNewRecPac(creatorID)

And here's the function
Function CanCreateNewRecPac(ByVal userID)
      Call LogThisMessage(userID,"- " & pageName & " Entered CanCreateNewRecPac Function$$F$$")
      On Error Resume Next
      dim strSQL
      dim rs
      
      if cstr(userID&"") = "" then userID = "-5"
      ' 1.BU HR 2.BU HR SUB GROUP 3.CORPORATE COMPENSATION MANAGER
      strSQL      =       " SELECT * FROM USER_ROLES WHERE (FLG_BU_REP =1 OR FLG_BU_SUB_REP =1  OR FLG_CORP_COM_MANAGER = 1 OR FLG_CORP_COMP_DIRECTOR = 1) AND (UPPER(USER_ID) = " & toSQL(ucase(trim(userID)),"String") & " )"
      Call LogThisMessage(userID,"- " & pageName & " SQL Query: " & strSQL)
      call openrs(rs, strSQL)
      if err.number <> 0 then
            Call LogThisMessage(userID,"- " & pageName & " ERROR OCCURED IN QUERY EXECUTION:" )
            Call LogThisMessage(userID,"- " & pageName & " =====START OF ERROR LOGGING=====")
            Call LogThisMessage(userID,"- " & pageName & " ERROR NUMBER:" & err.number)
            Call LogThisMessage(userID,"- " & pageName & " ERROR DESCRIPTION:" & err.Description)
            Call LogThisMessage(userID,"- " & pageName & " ERROR SOURCE:" & err.Source)
            CanCreateNewRecPac = false
            Call LogThisMessage(userID,"- " & pageName & " =====END OF ERROR LOGGING=====")
            call DisplayError (Err.Description)
      else
            Call LogThisMessage(userID,"- " & pageName & " Query was executed successfuly")
            if rs.eof then
                  CanCreateNewRecPac = false
                  Call LogThisMessage(userID,"- " & pageName & " Query returned empty RS and function was set to false")
            else
                  CanCreateNewRecPac = true
                  Call LogThisMessage(userID,"- " & pageName & " Query returned result and function return was set to true")
            end if
      end if
      On Error Goto 0
      If rs.State = 1 Then
            rs.close
            Call LogThisMessage(userID,"- " & pageName & " rs was Closed")
      end if
      set rs = Nothing
      Call LogThisMessage(userID,"- " & pageName & " rs was set to Nothing")
End Function


The logging in the function is recently added to help us know the problem and it's not deployed on the server yet.
Avatar of ko78

ASKER

ap_sajith,
We have string concatenations But I don't believe that it's the cause, why?
Because form the IIS logs I find that the pages that have the string concatenations are not called between the up and down times I only find the pages that I am talking about, I find them once up then down. with no any other pages in the middle.
I have revised the code twice and eliminated all the leakage that was there, so I don't think this is the reason as well.

About the threading model, it might be the reason can you tell me more about that? I don't know much about it.

I am not calling a COM object that I have created, but the virtual directory protection level is set to high which in turns create a component for the application. The virtual directory name is et, so there is a COM+ Application created called IIS-{Default Web Site//Root/et} I went in the tree and opened Components then IISWAM.1__Root__et the properties of this com object shows "Free Thread Apartment" under the concurrency tab, could this cause the error?

Thanks

After taking out the LogThisMessage (I assume they just log whats happening) the ON ERROR GOTO 0 jumped out at me, I would say that the ON ERROR RESUME NEXT is making it continue but the GOTO 0 send it back to the start - this might cause your infinate loop.

Maybe get rid of the GOTO
Avatar of ko78

ASKER

The on error resume next and on error goto 0 was added to turn on and off error handling that might be caused bye the logging function, these statements didn't exist before, and On error goto 0 in VB turns off error handling it doesn't change the execution path like goto statements in other languages

This is from the MSDN:
Use On Error GoTo 0 to disable error handling if you have previously enabled it using On Error Resume Next.

Thanks
My 2 cents, this line

 If rs.State = 1 Then

Where is RS instantiated here ? It has be in this function to check properties againts this.
Avatar of ko78

ASKER

In call openrs(rs, strSQL)

sub openrs(rs, strSQL)
      set rs = Server.CreateObject("ADODB.Recordset")
      rs.cursorlocation=3
      rs.open strSQL,connectionObject
      set rs.activeconnection = Nothing
end sub
Try adding

set rs=nothing
Set connectionObject=nothing

at the bottom of all the pages you are opening a recordset. Then only you will explicitly destroy the objects created. This is because marshalling (Cleanup) in ASP is not the best around.

Cheers!!
Avatar of ko78

ASKER

I have that already

This is executed in the function

If rs.State = 1 Then
          rs.close
          Call LogThisMessage(userID,"- " & pageName & " rs was Closed")
     end if
     set rs = Nothing
and the connection obect is set to nothing also at the end of the page,

You didn't tell me how to change the threading mode or how can it cause the problem

Thanks
I had mentioned the threading model incase you are using any Custom DLL's in your app. Go through this article on threading model.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/selectingathreadingmodel.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconapartmentmodelmultithreadinginvisualbasic.asp

Are you using any custom components?. Are they running in page scope?

Cheers!!
Avatar of ko78

ASKER

Just one component, it's a third party component, not found in the component services, I guess it's registered during the installation by regsvr32.
Sorry, Forgot about this Question... Whats the status with this?. Did you manage to solve this?. Do you need any further assistance?.

BTW.. Is there any specific errors listed in the Event Viewer?.

Cheers!!
Avatar of ko78

ASKER

yes I contacted MS development support center they found out that another application has halted the script engine
We are still in the phase of trrying to reproduce it and fix the problem
Thanks all for your help
That is always the problem of not having a dedicated server for each application....

FtB
Kindly close this question...Refer this link for help on how to close a question.

https://www.experts-exchange.com/help.jsp#hs5

Cheers!!
No issues...

Cheers!!
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'd be glad to hear if MS Development support was able to provide any solutions and what they were?  I've had a similar problem with my Exchange Outlook Web Access since installing SP4 on my Win2K Server.

Paul
Avatar of ko78

ASKER

They guided me that another application causes the Script engine to crash. I went to the Middle East Development Support Center. It was free.


Here's the link,
http://www.microsoft.com/middleeast/developers/meadsc/form.asp

You should submit your problem and they will answer you.

Hope your problem is solved soon isA
hello every body, I'm struck with the same situation. The operating system is Windows2000 running with service pack 4 and my application is ASP running on IIS 5. The web application was running fine for more than a year, but suddenly shows
dllhost.exe shooting to 100% cpu usage .
   I have checked the tips given by the experts like if there were any infinite loops, or session variable carrying conactenate strings,or huge arrays but no such problems were found.

    The dllhost.exe process can be killed.So the temporary solution i have did is setting a batch file to kill the dllhost.exe every 15 minutes thru scheduled task. But the problem is when ever the killing runs the website users get a message rpc service denied for a few sec,but on a refresh the web page turns to be normal

   Since i dont have any micrsoft subscribtion would like to know the workarounds or steps carried out by ko78, as he claims to have solved a similar situation.

    I have been running behind this for more than a week. Expecting a reply at the earliest.

Thanks in advance.

 
 

>> I have been running behind this for more than a week. Expecting a reply at the earliest.<<

Then you might want to consider posting a new question so that it gets attention by everybody rather than just those involved in this thread.

FtB
Hey  pk_sathishkumar,

I solved a similar problem with Microsoft patch KB818709 - go search it on their site.  Good Luck.