Memory Leaking Issue

Discussion in 'Site Programming, Development and Design' started by tjacoby, Nov 19, 2010.

  1. I currently have 3 application starting points, the first being a simple redirect page, the second being my primary websitem, and the third being a BlogEngine.net blog. I was trying to deploy a second site that utilized the Application object when I noticed the application kept restarting on me. I used Process.GetCurrentProcess().PrivateMemorySize64 to see how much memory was being used, and to my surprise the usage was skyrocketing!

    When deployed on my local machine with another web app running on it, total usage is ~70MB. When running it in Visual Studio 2010, usage is about 60MB. When deployed to the Winhost servers, usage seems to start around 65MB from what I can tell, but then it balloons up at a rate of about 2MB per second until it seems to peak around 150MB, whereupon the application pool is reset.

    I have gone through my code several times and added some efficiencies where I could, but I cannot figure out what is causing the memory usage to blow up like that. I do not store anything in session and I have tried to improve my SQL so it doesn't pull back larger sets than it has to. I have tried disabling my blog but that has had no effect.

    The part of my website that gets the most traffic is for my Craigslist counter. I get a request, update the database if the request is new from that URL, then build an image of the number of hits the page has received. This gets ~32,000 hits per week (see below). I cache the background image to save a little on resources used, but still memory usage just explodes! I set up a test in which I would request the image once every three seconds on my local machine and the memory usage just does not increase much at all.

    Any clue as to what's going on?

    [​IMG]
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    This is really hard because you have more then one web application running.

    The best way to troubleshoot this is to clear out your root for now and upload the applications one at a time and monitor the resource usage. This way you can pin point what web application is eating up a lot of memory.

    Remember you only have 1 application pool so any web application running under the same application pool will eat up memory.

    If budget permits you may want to start up several Basic accounts for now and upload your application there. Since the SQL server is a separate box you really do not need to update the connection string. Choose the month to month payment option so you can cancel the service at the end of the month once you are done testing it. Like I said this will depend on your budget. The basic plan is $4.95 a month so you'll need to weight out if you can afford the price even if it is for one month. Now you do not need to buy a domain name for these accounts. Simply use any domain name and use the secondary URL to view your site and the secondary FTP address to upload the web pages to our server.
     
  3. I suppose I could look into doing that, but like I said the one application is a simple redirect (probably ~10 lines of code), so I can't imagine that using any resources and I disabled the blog application starting point (which keeps it from running, right?) and the main site was still gobbling up memory like crazy...
     
  4. Ray

    Ray

    Yeah we can all assume that it will not consume any memory and most likely not so you may not want to troubleshoot that right away. All I'm saying is that things like this can be misleading and often times we fail to grasp the truth because we fail to let go our own mis-perception. There's really no magic way of doing this but to troubleshoot and test it one at a time separate from each other. If you don't want to spend the money then do it on your existing account. Wipe it clean and upload the web application one at a time and test it. This of course will mean that your main site will be down until you finish testing but if its really not in production then you should be OK; right?
     
  5. I have removed the application starting points for my main website and my blog. The only application running on my site right now is the root application. This is all the server code for that page:
    Code:
       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
                Dim strSubDomain As String = Request.ServerVariables("SERVER_NAME").ToString
                If strSubDomain = "blog.tomjacoby.net" Or strSubDomain = "www.blog.tomjacoby.net" Or strSubDomain = "blog.localhost" Then
                    Response.Redirect("http://www.tomjacoby.net/tomjacobyblog/")
                ElseIf strSubDomain = "test.tomjacoby.net" Or strSubDomain = "www.test.tomjacoby.net" Or strSubDomain = "test.localhost" Then
                    lblUsage.Text = Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024 & "MB"
                Else
                    Response.Redirect("http://www.tomjacoby.net/home/")
                End If
            End If
        End Sub
    You can see how the memory usage increases by going to http://test.tomjacoby.net/
     
  6. Ray

    Ray

    Is there a precompiled app? Why don't you just try running each app one at a time and see which one is causing the spike? Like I said the best way to find out is to delete them all and upload each app one at a time directly on the root.
     
  7. Haha because it takes forever to upload and download all those little files! I will do it now, though, at least my work connection is crazy fast.

    Ok I backed up all my stuff and deleted it from the server. I uploaded the root application to start and recycled the application pool just to be sure. If you go to that URL you can see the strange memory behavior is still there. There is nothing but the files necessary for that page to work present.
     
  8. And now I have done it with my main website and the memory issue continues. It does not seem to matter which application is running, they are all causing the memory usage to grow.
     
  9. Ray

    Ray

    Now try deleting this app and upload the other apps one at a time. Its possible that it is this app that is causing the spike and if we can verify that then we can start troubleshooting this specific app.
     
  10. Same goes for every application I try, and none of them have any traffic going to them because all of the referring links should be broken (they should all point to subdirectories and my applications are now at the root).
     
  11. Ray

    Ray

    That doesn't seem to make sense. Nothing on the server can make a web root cause it to utilize a lot of memory. Obviously every web service has to be loaded within the servers processor but that foot print is very little.
     
  12. I completely agree with you, it doesn't make sense. Do you have any other tips for narrowing down what the issue might be?
     
  13. I am nearly done moving my site to a server my house. All of my applications are running from here, live. My total memory usage is now hovering between 80 and 86MB, never more. "Tech support" here and through the ticketing system tells me that I am better off this way. I will be closing my site here soon.

    Thanks.
     
  14. i'm in a same situation, my web in local machine is over 70MB, but when I publish in Winhost, the memory reach 180 or more!! What happens in Winhost servers??
     
  15. Ray

    Ray

    The Winhost servers itself does not add any memory usage to the application. Keep in mind that each site account carries one application pool therefore if you have multiple web applications running under one site account that can consume more of the servers memory. It is a common mistake that the owner only downloads that one specific application in there test server and monitor the resource usage, but in fact you need to download all the applications on the test server and run it under one application pool so you can get an accurate reading of the resource usage. Furthermore, keep in mind that once you upload it to the server there are more users calling on it. So you also need to mimic the same activity on your test environment like you would get on your production box.
     
    Last edited by a moderator: Oct 14, 2015
  16. Just as an update, my site hosted locally (all applications running in one pool) now consumes about 125MB of memory. This is after I have increased functionality of a couple applications and traffic has increased. It is not ballooning like it did before. I do not know what was happening at Winhost, but you should figure it out because it is a legitimate problem, as much as you want to say "it shouldn't happen."
     
    Last edited by a moderator: Oct 14, 2015
  17. Ray

    Ray

    125 MB of memory usage is quite a lot. If you are on the Basic plan, your application pool would have certainly been recycled.
     
  18. I have the same problem with memory consumption. First I tried to look into to the code of my website, however after several attempts to find memory leaks in my code I've tried the following test:
    - I have created a simple test web site consisting of 4 aspx pages containing links to eachother and an image. Each page shows current memory consumption. No other content is present on those pages. When tested localy (IIS 5.1 on WinXP, II7 on Win7) memory consumption growth is +1MB per 5hits. When tested on Winhost hosting memory consumption growth is about +3MB per hit! It increases untlill 100MB+ and then goes down to 90MB or so and never goes lower untill the pool is recycled...
     
    Last edited by a moderator: Oct 14, 2015
  19. Ray

    Ray

Share This Page