Memory usage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Morris

    Memory usage

    I understand how .NET will force a garbage collection before an out of
    memory exception etc, but I am still concerned with how much memory my .NET
    app seems to hold onto according to the task manager.

    Constantly my apps (all running via terminal services on the same machine)
    are reaching around 100MB per user (8 - 15 users), but this drops down to
    8MB when the app is minimised so I know I am not at fault myself!

    I am guessing that the GC collects .NET objects but doesn't necessarily give
    the ram back to Windows. Is there anything I can do about this? I'd like
    my .NET app to be more memory friendly to other apps on the machine.


    Thanks

    Pete

  • Peter Duniho

    #2
    Re: Memory usage

    On Wed, 09 Jul 2008 08:57:44 -0700, Peter Morris
    <mrpmorrisNO@SP AMgmail.comwrot e:
    [...]
    I am guessing that the GC collects .NET objects but doesn't necessarily
    give the ram back to Windows. Is there anything I can do about this?
    I'd like my .NET app to be more memory friendly to other apps on the
    machine.
    Rest assured, it is. What you see in Task Manager is a teeny tiny
    snapshot of an instant in time, and doesn't tell you anything at all about
    how your .NET application affects other processes that may be running on
    the computer at the same time.

    If you find a situation where your application could have returned memory
    to the OS but hasn't and another process is suffering because of that,
    _then_ you can start worrying. Until then, just trust that .NET knows
    what it's doing. That's why you use the framework in the first place.

    Pete

    Comment

    • Brian Rasmussen [C# MVP]

      #3
      Re: Memory usage

      As Peter said the CLR does release memory to the OS. However, it usually
      holds on to allocated memory for a little while longer than absolutely
      needed in case memory new allocations should request more memory. Allocating
      memory is not a cheap operation, so this makes sense.

      --
      Regards,
      Brian Rasmussen [C# MVP]




      "Peter Morris" <mrpmorrisNO@SP AMgmail.comwrot e in message
      news:eNkRJyd4IH A.4800@TK2MSFTN GP02.phx.gbl...
      >I understand how .NET will force a garbage collection before an out of
      >memory exception etc, but I am still concerned with how much memory my .NET
      >app seems to hold onto according to the task manager.
      >
      Constantly my apps (all running via terminal services on the same machine)
      are reaching around 100MB per user (8 - 15 users), but this drops down to
      8MB when the app is minimised so I know I am not at fault myself!
      >
      I am guessing that the GC collects .NET objects but doesn't necessarily
      give the ram back to Windows. Is there anything I can do about this? I'd
      like my .NET app to be more memory friendly to other apps on the machine.
      >
      >
      Thanks
      >
      Pete

      Comment

      • Chakravarthy

        #4
        Re: Memory usage

        Did you ever got to know about CLR Profiler.. try this, you will understand
        in detail as why you see the differences in the memory sizes.

        HTH



        "Peter Morris" <mrpmorrisNO@SP AMgmail.comwrot e in message
        news:eNkRJyd4IH A.4800@TK2MSFTN GP02.phx.gbl...
        I understand how .NET will force a garbage collection before an out of
        memory exception etc, but I am still concerned with how much memory my
        .NET app seems to hold onto according to the task manager.
        >
        Constantly my apps (all running via terminal services on the same machine)
        are reaching around 100MB per user (8 - 15 users), but this drops down to
        8MB when the app is minimised so I know I am not at fault myself!
        >
        I am guessing that the GC collects .NET objects but doesn't necessarily
        give the ram back to Windows. Is there anything I can do about this? I'd
        like my .NET app to be more memory friendly to other apps on the machine.
        >
        >
        Thanks
        >
        Pete

        Comment

        Working...