开发者

Visual Studio 2010 - High CPU Utilization after website build

开发者 https://www.devze.com 2023-03-18 12:15 出处:网络
I am working on a VB.NET website in Visual Studio 2010. The project is set to run the website in the local instance of IIS 7. If I simply access the website, http://localhost/mywebsite, the website pe

I am working on a VB.NET website in Visual Studio 2010. The project is set to run the website in the local instance of IIS 7. If I simply access the website, http://localhost/mywebsite, the website performs normally and the process w3wp.exe jumps around 2-3% CPU utilization as I would expect. As soon as I run a build of the website in Visual Studio, the w3wp.exe process jumps up to 25% CPU utilization, and it stays there as I flip over to IE and test the website. If I build again, the w3wp.exe process jumps up to around 50% CPU utilization, and it stays there as I flip over to IE again and test the website. This process continues till I reach 90-100% CPU usage, and I have to kill the w3wp.exe process so that the website starts over again.

Does anyone know why this is happening, and how to resolve it. I assume this has something to do with Visual Studio overwriting DLLs that IIS is trying to use. Would it be best to add an app pool reset command to the post build tasks?

I acknowledge that I could run IIS Express or the Visual Studio Development Server, but we prefer to test using a full version of IIS 7 to make sure we have an identical testing environment to production.

Thank you for any help you can give.

Edit I have narrowed down the problem. I have found, after Jeremy asked below about anything running in Application_Start, that the problem is a result of the code I have in application start. If I comment out my code to load some static collections with data, I do not get the spike in CPU on rebuild. So based on that, do you know why when I rebuild the project the CPU would spike based on some code to load a static collection with data?

This is an example of what I am doing to load the static object with data:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    MyObjects.Load(connectionString)
End Sub    

Public Class MyObjects
    Private Shared _objects As Dictionary(Of String, Dictionary(Of String, MyObject)) = Nothing
    Private Shared _lockObject As New Object
    Private Shared _connectionString As String = Nothing

    Shared Sub New()
    End Sub

    Shared Sub Load(ByVal s As String)
        Dim qry As StringBuilder = Nothing
        Dim dt As DataTable = Nothing
        Dim tempDefHolder As Dictionary(Of String, Dictionary(Of String, MyObject)) = Nothing

        qry = New StringBuilder()
        qry.AppendLine("my query")

        _connectionString = s

        dt = New DataTable()

        Using conn As New OracleConnection(_connectionString)
            Using cmd As New OracleCommand(qry.ToString(), conn)
                Using da As New OracleDataAdapter(cmd)
                    conn.Open()
                    da.Fill(dt)
                End Using
            End Using
        End Using

        tempDefHolder = LoadMyObjectsFromDataTable(dt) '(turns datatable into dicti开发者_开发百科onary of objects

        'assign _objects using synclock
        SyncLock _lockObject
            _objects= tempDefHolder
        End SyncLock
    End Sub
End Class

Another Edit Currently the app is configured to run as 64bit in IIS 7, but it is compiled for "Any CPU". If I change the app pool in IIS to "Enable 32-bit applications" so that it runs in 32 bit mode, the CPU spike does not occur when I rebuild as it does when the app is running in 64 bit mode.


After many wasted hours trying to figure this out. I narrowed the problem down to my version of the 64 bit ODP.net dll. I just went to Oracle's site and downloaded the newest update to ODP.net, and the problem is fixed. It must have been a bug in their code that they fixed somewhere between my version and the newest version.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号