Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - CPU at 100%
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CPU at 100%

 Post Reply Post Reply
Author
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Topic: CPU at 100%
    Posted: 12 August 2006 at 2:48pm
Hi all

I have small problem. I have found a small script written in aspx and  every time i try to open a page in browser my CPU goes to 100% right away and it take up to 1min or more for page to load.

I have .net Framework 2.0 installed.

The thing is that from the beginning the page loaded ok, but after a month  when i was actually trying to start learing aspx the page need lots of time to load and CPU is at 100% always.

I reinstalled framework, but same thing occur.

Can you give me some suggestions what should I do so that asp.net would run normaly?

Thanks,




Edited by urko - 12 August 2006 at 2:49pm
Urko
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2006 at 3:09pm
Show the script. What is it doing etc? .net has plenty of performance counter built into you can try if you don't want to share the script....
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2006 at 4:09pm
Sorry here is the index.aspx.

I have found this script on web.....

[code]
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>

<script runat="server">

'++++++++++++++++++++++++++++++++++++++++++++
  'Handle the page load event
  Sub Page_Load(Sender As Object, E As EventArgs)

         'Display all categories
         Display_Category()

         'Call Total Link Count - get the number links
         Total_Link_Count()

         'Call Newest links
         Newest_Links()

         'Call MostPopular Sub - Display 15 most popular links
         Most_Popular_Links()

         'Call risplay link name A to Z
         Display_Letter_Links()

         'Call Random link
         Random_Link_Number()
         Random_Link()

         lblletter.Text = "Link Name A-Z:"
     
 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 'Display all categories with count
 Sub Display_Category()

strSQL = "SELECT *, (SELECT COUNT (*)  FROM LINKS WHERE LINKS.CAT_ID = CATEGORY.CAT_ID AND LINK_APPROVED = 1) AS REC_COUNT FROM CATEGORY ORDER BY CAT_NAME ASC"
   
         'Call Open database - connect to the database
         DBconnect()

         Dim LinkAdapter as New OledbDataAdapter(objCommand)
         Dim dts as New DataSet()
         LinkAdapter.Fill(dts, "CAT_ID")

         lbltotalCat.Text = CStr(dts.Tables(0).Rows.Count) & "&nbsp;categories"

         LinkCat.DataSource = dts.Tables("CAT_ID").DefaultView
         LinkCat.DataBind()

         'Close database connection
         objConnection.Close()

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
  'Show an Item in a Bound List - Display sub categories
  'This is not the best way to query the sub-categories name. After many attempts, I decided to use this method and it works. I'm not sure
  'hos this affect the performance, since it use nested queries.
  Sub LinkCat_ItemDataBound(sender As Object, e As DataListItemEventArgs)
    
    'First, make sure we're not dealing with a Header or Footer row
    If e.Item.ItemType <> ListItemType.Header AND e.Item.ItemType <> ListItemType.Footer then

       Dim intCatID as integer
       Dim strSQL2 as string

       intCatID = DataBinder.Eval(e.Item.DataItem, "CAT_ID")

       Dim subnamelabel As Label = CType(e.Item.FindControl("lblsubname"), Label)

       'SQL display details and rating value
       strSQL2 = "SELECT * FROM SUBCATEGORY WHERE CAT_ID=" &  intCatID & " Order by SUB_NAME DESC"

       Dim objDataReader as OledbDataReader

       objConnection = New OledbConnection(strConnection)
       objCommand = New OledbCommand(strSQL2, objConnection)

       objConnection.Open()
       objDataReader  = objCommand.ExecuteReader()

       'Read data
        objDataReader.Read()

        Dim intSID as integer = objDataReader("SUB_ID")

subnamelabel.text = subnamelabel.text & "<a class=""dt3"" title=""Go to " & objDataReader("SUB_NAME") &" Sub-Category"" href=""pageview.aspx?tab=" & 1 & "&catid=" & intCatID & "&subid=" & intSID & """>" & objDataReader("SUB_NAME")  &  "</a>"
     
      objDataReader.Close()
      objConnection.Close()

       Dim intCatID2 as integer
       Dim strSQL3 as string

       intCatID2 = DataBinder.Eval(e.Item.DataItem, "CAT_ID")
       Dim subnamelabel2 As Label = CType(e.Item.FindControl("lblsubname2"), Label)

       'SQL display details and rating value
       strSQL3 = "SELECT * FROM SUBCATEGORY WHERE CAT_ID=" &  intCatID2 & " Order by SUB_NAME ASC"

       objConnection = New OledbConnection(strConnection)
       objCommand = New OledbCommand(strSQL3, objConnection)

       objConnection.Open()
       objDataReader  = objCommand.ExecuteReader()

       'Read data
       objDataReader.Read()

        Dim intSID2 as integer = objDataReader("SUB_ID")

subnamelabel2.text = subnamelabel2.text & "<a class=""dt3"" title=""Go to " & objDataReader("SUB_NAME") &" Sub-Category"" href=""pageview.aspx?tab=" & 1 & "&catid=" & intCatID2 & "&subid=" & intSID2 & """>" & objDataReader("SUB_NAME")  &  "</a>..."
     
      objDataReader.Close()
      objConnection.Close()

   End if

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
  'Display the alphabetical letter listing in the footer
  Sub Display_Letter_Links()

      Dim i as Integer
      lblalphaletter.Text = string.empty

       for i = 65 to 90   
         lblalphaletter.text = lblalphaletter.text & "<a href=""pageview.aspx?tab=2&l=" & chr(i) & chr(34) & _
" class=""letter"" title="& chr(i) & ">" & chr(i) &  "</a>&nbsp;&nbsp;"
      next

 End Sub
'++++++++++++++++++++++++++++++++++++++++++++



'++++++++++++++++++++++++++++++++++++++++++++
 'Sub Display 15 newest links
 Sub Newest_Links()
     &nbs
Urko
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2006 at 7:35pm
OK, did that to myself asking for the script but after woosing through some of the script, it appears you are dealing with an endless loop at the child-link iteration. Built-in some error checking (try catch) and set an upperbound for sub-links to always drop out of the loop...
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.