W3wp.exe high cpu utilization

creditpointe
creditpointe used Ask the Experts™
on
Hello,

We are having a asp.net application. We have deployed the application in IIS 7.0 on Windows server2008. The problem is that after 5-6 request if we check the memory utilization of the w3wp.exe, it shows almost 100% memory utilization. Because of which the server becomes slow.And nothing can be done. We have to kill the w3wp.exe process and then only the memory gets free.
Even after logging off the memory is not getting freed. And w3wp.exe retains the amount of memory allocated to it.
We have created separate application pool for our application but still the problem exists. Would you please help me out.

Thanks & Reagrds,

Tushar
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Vikas ShahCurrently Seeking Opportunities

Commented:
Hey creditpointe,

Use Log Parser to find the cause of it.. you can run the below mentioned command.

"C:\> logparser "select top 10 cs-uri-stem, time-taken from  ex071105.log group by cs-uri-stem order by time-taken desc" -q:on"

Or

Installed the application called IISpeek. This will help you to narrow down the issue.

Regards,

Vikas Shah

I downloaded IISPeek and the next time we saw the CPU max out, we were able to find the problem page instantly.

Author

Commented:
Hello shahvikas/monstermark,

Thanks for reply. We have tried both the thing which we explained. But unable to find anything fruitful. Still we are having the same problem. We had done changes in our code in order to free as much as memory we can but still facing the same problem. Would you please let us know how would we check the memory utilisation by w3wp.exe from going to 100%.

Thanks in advance.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Vikas ShahCurrently Seeking Opportunities

Commented:
Please refer to the below mentioned article. This may help:
http://support.microsoft.com/kb/916984
Please let me know the status.
Regards,
 

Author

Commented:
Thanks shahvikas for your reply.
We are using IIS 7 and windows server 2008. The microsoft article which you are mentioning is about the hotfix for IIS 6.0 and windows server 2003.
Is there any such hotfix for windows server 2008.

Regards,
Vikas ShahCurrently Seeking Opportunities

Commented:
As such there are no Hotfixes for the same when it comes to the IIS7.0.

The issue still exists or it is sorted out now.

Please let us know the current status for the same.

Regards,

Vikas

Author

Commented:
Thanks shahvikas,

for your response. The issue is still exists and we trying everything that we can do. We have done memory profiling of our application for any memory leaks and implemented the suggestions. But still unable to resolve the issue.

If you have anything more on it please let us know...

Thanks once again..

Regards,
Commented:
Finding the reason for the high CPU utilization can take some time since you will have to locate the code that is causing the problem. I am working through this right now on a vb.net app that I recently developed. In the meantime, I have developed a page that has a button which an Administrative user can click to stop the W3WP.exe process. It is a great stop gap measure until the problem code can be identified and updated. Here is the code I used. Just create a .aspx page with a button that call the following code on the corresponding .aspx.vb page. The code uses the command prompt to get the Tasklist and writes this to a file. I then parse the text file for the PID of the W3WP.exe worker process. Then, I access the command prompt programmatically again to terminate the W3WP.exe process using the PID.

Imports System.Web

Partial Class TAP
    Inherits System.Web.UI.Page

    Protected Sub btnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStop.Click
        Call thStop_IIS()
    End Sub

    Function thStop_IIS()

        Dim varRetval As String
        Dim varPID As String
      dim x as long
        Dim savePath As String = Request.PhysicalApplicationPath + "exports\"
        If Dir(savePath + "filename.txt") = "filename.txt" Then
            Kill(savePath + "filename.txt")
        End If

        varRetval = Shell("cmd /c tasklist > " + savePath + "filename.txt")

        For x = 1 To 90000000

        Next x

        varPID = thParse_File_Return_PID(savePath + "filename.txt")
        varRetval = Shell("cmd /c taskkill /pid " & varPID & " /F")
        Return True
    End Function

    Function thParse_File_Return_PID(ByVal varFileToParse As String) As Integer

        On Error GoTo handler_err

        Dim FILE_NAME As String = varFileToParse
        Dim TextLine As String
        Dim varPID As Integer
        Dim x As Long

        If System.IO.File.Exists(FILE_NAME) = True Then

            Dim objReader As New System.IO.StreamReader(FILE_NAME)

            Do While objReader.Peek() <> -1
                'TextLine = TextLine & objReader.ReadLine() & vbNewLine
                TextLine = objReader.ReadLine() & vbNewLine
                If InStr(TextLine, "w3wp.exe") Then
                    varPID = Mid(TextLine, 31, 4)
                End If
            Loop

            thParse_File_Return_PID = varPID

        Else
            thParse_File_Return_PID = 0
        End If



handler_exit:
        Exit Function

handler_err:
        'MsgBox(Err.Number & " " & Err.Description & ":" & thParse_File_Return_PID
        Resume

    End Function

End Class

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial