Troubleshooting Memory Leaks

Discussion in 'General troubleshooting' started by Randy, Aug 24, 2016.

  1. Hello,

    My application is having issues with memory leaks. At the suggestion of the help desk I have turned on the http logging as a tool.

    As I understand, the technique for finding memory leaks is to correlate a spike in memory (as seen in the control panel historical usage) with activity in the http log, to isolate the code causing the problem.

    For something as common as parsing IIS logs must be, there seems to be a dearth of tools for it. For anyone interested, the combination of MS Log Parser https://www.microsoft.com/en-us/download/confirmation.aspx?id=24659 along with Office Log Parser Studio https://gallery.technet.microsoft.com/office/Log-Parser-Studio-cd458765 allows the logs to be viewed in a columnar format and also queried. Very handy.

    Today, my control panel showed a sharp increase in memory usage beginning after 7AM until about noon (the time reported by the control panel and not my local time). An inspection of the logs revealed that nobody used my site during that time -- only bots, and the SiteLock spider. So I'm not sure what to make of that.

    So here are some questions for the community:
    • Is there a better way to be going about this?
    • Does control panel report using the same time zone used by IIS?
    • After observing the problem today I 'recycled' the application in control panel and the memory usage came down. Does doing this disconnect or disrupt anyone logged in at the time?
    Thank You!
    Randy Craven
     
  2. mjp

    mjp

    Yes, both of those should be Pacific time.
    That depends on how you're handling those sessions.

    Is this something you wrote yourself or is it a third party application?
     
  3. Thank you, mjp.

    I wrote the application, and I'm using InProc for the session state.

    My application is MVC and uses encrypted session cookies to handle the state information it needs. It doesn't use the session state in the way I remember from doing WebForms.

    I ran an experiment with my beta site by logging in and then recycling. It did appear to cause me to lose my session; the site stayed up but was unresponsive until I logged out and back in.

    So I guess that's my answer. Would you agree?

    Thanks again.

    Randy
     
  4. mjp

    mjp

    It sounds like you're on to the problem, yes. I'll see if I can't get someone who knows more about it than I do to chime in...
     
  5. Martin Ortega

    Martin Ortega Everleap staff

    Hi Randy,

    If you're using InProc and you recycle your application. You will lose your sessions if the application pool is recycled. To keep the sessions we recommend using SQL Server sessions. That way you keep your sessions on the database. So even if the application pool is recycled. The sessions lives in the database.

    If you want to enable SQL Server sessions. Create a database in the control panel. Then contact our support department and tell them you want to enable sessions on the database.
     
  6. Martin Ortega

    Martin Ortega Everleap staff

    I forgot to add. If you don't wish to use SQL Server sessions. You might want to consider using one of our Reserve instances. http://www.everleap.com/cloud-hosting/features/reserved-cloud-servers/

    We allow you to try it out to see if you like it. Just contact support and tell them what reserve instance you wish to try out 1 GB, 2 GB, or 4 GB and we'll let you test it out for a couple of days to see how you like it.
     
  7. Hello Martin, and thanks for your messages.

    I read in the link from mjp that InProc is the choice for best performance. So maybe we will stick with that for the moment. The memory leak issue has been very sporadic, maybe twice a month. Hopefully I can find and fix the issue before it becomes a larger problem.

    We recently did go to a reserved server, mainly just to have more memory available as a stopgap measure. But does the reserved server change anything about what happens when the application is recycled?

    Thanks!
     
  8. mjp

    mjp

    If you're running a Reserved Cloud Server the main difference is there is no idle time-out, so the application will not recycle due to inactivity. But the effects of a recycle for any other reason remain the same.

    (And while there is no idle time-out on the Reserved Server, your application will recycle if/when memory use exceeds your quota.)
     
  9. Thanks, mjp.

    Since the control panel only reports memory usage once per hour, and the log files can contain several thousand entries per hour, this is proving hard to pin down.

    Has anyone used the commercial profilers available such as dotMemory or Ants?

    Thanks, Randy
     
  10. I am not sure if this might help, but our app processes images--some of which could be quite large and consume a substantial amount of memory. When executing back-to-back requests, the second often faulted on insufficient memory. The code is straightforward and we were releasing all resources. At the end of each invocation we forced garbage collection using GC.Collect() This resolved the memory issue for our particular circumstance--so I thought I would pass it along.
     
    Ray Huang likes this.

Share This Page