Forums & Blog

A SmarterTools-sponsored community.
Welcome to Forums & Blog Sign in | Join | Help
in Search

Memory issue on VPS with IIS website

Last post 09-11-2008 9:10 AM by jerger. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-17-2008 10:19 AM

    • GWAB
    • Top 200 Contributor
    • Joined on 12-12-2007
    • Chicago
    • Posts 53

    Memory issue on VPS with IIS website

    I have solved my memory issue on my Windows VPS. My scenario:

    Windows 2003 VPS on Virtuozzo with 384 MB of RAM, Smartermail enterprise configured for IIS website.

    My issue was that the IIS worker process, w3wp.exe, would skyrocket to 170 MB of memory usage as soon as the first person connected to the webmail. Over the course of a day, the process would not hand memory back to the OS, my system would slow down and eventually crash with the following events in the application log:

    Event Type:  Warning

    Event Source:         ASP.NET 2.0.50727.0

    Event Category:      Web Event

    Event ID:      1309

    Description: Event code: 3005 Event message: An unhandled exception has occurred...

    And

    Event Type:  Error

    Event Source:         .NET Runtime

    Event Category:      None

    Event ID:      0

    Description:... .NET Runtime version : 2.0.50727.1433 - Application Error.

    The short story is, modifying the Aspnet.config file with <gcServer enabled=”false”/> solved my issue. (Microsoft article ID 911716)

    The long story is – The .NET language runtime environment absolves the developer from worrying about tracking and freeing memory. Instead the developer can focus on what the code is supposed to do, while garbage collection manages memory for the .NET application. On a multiprocessor system garbage collection will consume a lot of memory because it creates one heap per processor for parallel collections. Thus, the w3wp.exe process will start and quickly consume a large amount of memory on a multiprocessor system.

    The catch – how often does a system have 4 processors (as seen in Task Manager) and 384 MB of physical memory? With Virtuozzo this may be more common than you think. I learned about Virtuozzo when I researched Windows hosting to find an inexpensive VPS. Whereas VMWare and Virtual Server will virtualize the hardware, creating a completely separate environment for the guest OS, Virtuozzo runs the virtual private servers as instances of the base (or hardware) OS. Apparently I am seeing the 4 processors that exist on the base OS. And so is ASP.NET. Thus ASP.NET created one heap per processor, immediately consuming 170 MB of memory on my 384 MB VPS.

    Modifying the Aspnet.config file to force .NET to work in Workstation mode (using only one heap) reduced memory of w3wp.exe to 55 MB upon start.

    Most people with multiprocessor systems have gigabytes of memory and probably don’t care that w3wp.exe consumes what it does. In fact, your performance will be improved by running the garbage collector in server mode.

    Finally, you may be asking, why didn’t Asp.net give memory back when the OS needs it, as it should?? Apparently garbage collection will reduce the committed bytes of memory but not actually give the memory back to the OS. This results in performance improvements for .NET. The garbage collection will give memory back when a low memory notification event occurs, which is when a threshold of X MB is left on the system. Apparently the threshold is too low and garbage collection is not quick to respond.

    As I read through my many Microsoft KB articles, I finally realized that the exception information in the 1309 event “Exception type: OutOfMemoryException” really meant I was out of memory. The w3wp.exe was not giving it back to the OS. At least not quick enough to prevent application errors and services failing.

    References –

    Excellent overview of .NET memory usage with the good and the bad,

    http://weblogs.asp.net/pwilson/archive/2004/02/14/73033.aspx

    Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework

    http://msdn.microsoft.com/msdnmag/issues/1100/gci/

    How to modify the Aspnet.config for Workstation mode of Garbage Collection

    http://support.microsoft.com/kb/911716

    Side note: In the properties for the SmarterMail application pool, setting the “recycle worker processes at the following times” isn’t a bad idea. This is more graceful than a iisreset or reboot to clean up memory. I have mine with one time in the middle of the night.

  • 03-06-2008 1:23 PM In reply to

    Re: Memory issue on VPS with IIS website

     Hi Gwab,

     I am having a similiar issue except I get the 'System.OutOfMemoryException' on the MailService not the w3wp process. Any suggestions? My w3wp process is only running at 43mb. But my MailService is constantly using 120mb to 220mb. 

  • 03-06-2008 1:38 PM In reply to

    Re: Memory issue on VPS with IIS website

    I've been considering a VPS solution for some time, but between SpamD and the other SM processes I just can't see how 512mb can possibly run SmarterMail + SmarterStats + IIS. On a dedicated server w/ 2048mb I was running at about 75-80% usage when SpamD was really churning. SmarterTools Suites are standard with a few VPS providers, including HostMySite and ServerIntellect -- I would love to hear how others are running these small memory VPS instances.
  • 03-07-2008 8:15 AM In reply to

    • GWAB
    • Top 200 Contributor
    • Joined on 12-12-2007
    • Chicago
    • Posts 53

    Re: Memory issue on VPS with IIS website

    Do you have multiple processors and if so did you try modifying the aspnet.config file? The best first step is to make certain you are up to date with ASP.net. Do you have SP1 for .net framework 2 installed? 

  • 03-07-2008 8:17 AM In reply to

    • GWAB
    • Top 200 Contributor
    • Joined on 12-12-2007
    • Chicago
    • Posts 53

    Re: Memory issue on VPS with IIS website

    If you prefer to run you own anti-spam, I would not recommend a VPS. If you go with hostmysite, you can easily run SM + IIS without and issue, and then pay the $1/mailbox for Postini. I am not running SmarterStats so I can not comment on that.  

  • 03-07-2008 8:32 AM In reply to

    Re: Memory issue on VPS with IIS website

    GWAB:

    Do you have multiple processors and if so did you try modifying the aspnet.config file? The best first step is to make certain you are up to date with ASP.net. Do you have SP1 for .net framework 2 installed? 

     

     

    Yes I modified aspnet.config. Where do I check what service pack I have for .net?  

  • 08-05-2008 5:55 AM In reply to

    Re: Memory issue on VPS with IIS website

     i set it last night to clear the memory at 2am in iis... hope that helps

     

    im going to research his other ideas 

  • 09-11-2008 9:10 AM In reply to

    Re: Memory issue on VPS with IIS website

    this causes the same issues for me:

    <gcServer enabled="false"/>
     
    i have 2 cpus, and 4gb ram.. i'm going to try this today:
    <gcServer enabled="true"/> 

     

Page 1 of 1 (8 items)