none
.net application ran out of memory only in windows 2003 server RRS feed

  • Question

  • As title, I encountered an out of memory issue in windows 2003 server,
    but application is without exception in windows XP.

    Beside, I add Garbage Collection to flush memory during the application running, it is work in windows 2003 server.

    Are there any idea to solve this issue?

    Thanks for your help,

    Ryan

    Monday, December 29, 2008 6:33 AM

Answers

  • The CLR uses a different garbage collection strategy on servers.  It runs less frequently.  That's consistent with your problem, there's a greater chance that you'll get OOM when you are already pushing the limit.  To disable server mode collection, create a .config file with the <gcServer> element, enabled = false.  But you'd better review your code too, making sure you call Dispose() where necessary and have a reasonable upper limit on memory hogs like DataSet.

    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, January 2, 2009 12:40 PM
    Thursday, January 1, 2009 5:38 PM
    Moderator

All replies

  • Can you provide more details about the application?  Are you using any gc-related settings in your configuration file, like gcConcurrent, gcServer..?
    Monday, December 29, 2008 7:03 AM
  • It's work in Windows 2003 server, after I enforce to flush memory by following code

        try
       {
        GC.Collect();
        GC.WaitForPendingFinalizers();
        
        if (Environment.OSVersion.Platform == PlatformID.Win32NT)
        {
         SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
        }
       }
       catch(Win32Exception )
       {
       }  
    Monday, December 29, 2008 9:38 AM
  • A bunch of questions:
    + Are you allocating big objects in your application? 
    + Do the win2k3 server & XP machines have different configurations (memory, etc.)? 
    + Did you notice low memory when this happens?
    + Can you paste the whole exception that you're getting?
    + Does this issue reproduce consistently?

    Monday, December 29, 2008 6:34 PM
  •   A bunch of questions:
    + Are you allocating big objects in your application? 
    YES, application gets volumes data from MSDE, modifies the data then save back to MSDE.

    + Do the win2k3 server & XP machines have different configurations (memory, etc.)? 
    Hardware spec is following,
    win2k3 server:
      Xeon 3.2Ghz + 4GB RAM
    win xp:
      Core 2 2.13Ghz + 2GB RAM
    I don't think this problem is related to hardware spec.
    Because I tested in 5 machines (2 are xp and 3 are win2k3 server) at least, and all spec. are not the same.

    + Did you notice low memory when this happens?
    No.
    Sometime, application can run successfully with same data in win2k3 server.
    But, it will fail (Out of memory) at 2nd run.
    I monitored the memory.
    It seems win2k3 server doesn't release memory properly after 1st run, and memory increase fast and strange at 2nd run.

    + Can you paste the whole exception that you're getting?
    May I update the exception message later?

    + Does this issue reproduce consistently?
    YES
    Tuesday, December 30, 2008 9:45 AM
  • Thanks for the answers!  Few more:

    1.  Is this ASP.NET application?
    2.  Are you closing SQL connections after each run?

    Also, here are some links on how you can try to investigate this issue using windbg and other tools:

    http://msdn.microsoft.com/en-us/magazine/cc163528.aspx
    http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx
    Tuesday, December 30, 2008 5:45 PM
  • 1.  Is this ASP.NET application?
    No, it is a windows application.
    2.  Are you closing SQL connections after each run?
    Yes

    Thanks for your great support, I will do further investigation with your suggested tools and update soon.
    Thursday, January 1, 2009 4:13 PM
  • The CLR uses a different garbage collection strategy on servers.  It runs less frequently.  That's consistent with your problem, there's a greater chance that you'll get OOM when you are already pushing the limit.  To disable server mode collection, create a .config file with the <gcServer> element, enabled = false.  But you'd better review your code too, making sure you call Dispose() where necessary and have a reasonable upper limit on memory hogs like DataSet.

    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Friday, January 2, 2009 12:40 PM
    Thursday, January 1, 2009 5:38 PM
    Moderator
  • Thanks for your help.
    I done the test with a configuration file as your mention, but OOM issue is still there.
    Sunday, January 4, 2009 5:31 AM