Runtime and OS report different mem usage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geng Sheng

    #1

    Runtime and OS report different mem usage

    Hi
    I am working on a pure managed windows application that creates large byte arrays at run time. In fact it creates a 50M byte array when the application starts

    public static byte[] buffer = new byte[1024*1024*50]

    I am using System.GC.GetTo talMemory() to monitor the memory usage. It is consistent with what I can imagine. The memory usage is a little bit above 50M. During runtime this application reads large files (between 25 to 46MB) but it does not reallocate buffer. Each time only one file can be processed and the above 50MB buffer is used

    However, if I use Windows Task Manager/Processes and check the memory usage of this application, I see the memory usage is between 75 to 130 MB. This result in some serious diskswapping activities on a PC with 256MB memory

    Do you know why there is a discrepency of mem usage between the runtime reports and what the OS reports

    I am using .NET SDK1.1 on XP Pro and Win Server 2003

    Thank you for your help


  • Willy Denoyette [MVP]

    #2
    Re: Runtime and OS report different mem usage


    "Geng Sheng" <anonymous@disc ussions.microso ft.com> wrote in message
    news:683020A6-03A7-490E-867E-C15B159BEAF7@mi crosoft.com...[color=blue]
    > Hi,
    > I am working on a pure managed windows application that creates large byte
    > arrays at run time. In fact it creates a 50M byte array when the
    > application starts.
    >
    > public static byte[] buffer = new byte[1024*1024*50];
    >
    > I am using System.GC.GetTo talMemory() to monitor the memory usage. It is
    > consistent with what I can imagine. The memory usage is a little bit above
    > 50M. During runtime this application reads large files (between 25 to
    > 46MB) but it does not reallocate buffer. Each time only one file can be
    > processed and the above 50MB buffer is used.
    >
    > However, if I use Windows Task Manager/Processes and check the memory
    > usage of this application, I see the memory usage is between 75 to 130 MB.
    > This result in some serious diskswapping activities on a PC with 256MB
    > memory.
    >
    > Do you know why there is a discrepency of mem usage between the runtime
    > reports and what the OS reports?
    >
    > I am using .NET SDK1.1 on XP Pro and Win Server 2003.
    >
    >
    > Thank you for your help.[/color]


    What counters are you looking at in the Taskmanager?
    The Taskmanager has no counter for the GC.GetTotalMemo ry value, so you are
    actually comparing two different things.
    If you need a consistent view of the memory consumption, start the
    performance managed and look at the CLR Memory counters category.

    Willy.


    Comment

    • Geng Sheng

      #3
      Re: Runtime and OS report different mem usage

      I am using Windows Task Manager\Process es by press control-alt-delete then choose "task list". It is a table with the following columns
      Image Name, PID, CPU, CPU Time, Mem Usage

      I then found the application process name and check the Mem Usage here. By the way, I tried to use PerfMon but I do not know how to enter a specific "Image Name" in those memory counters

      On the other hand I am using System.Console to write out System.GC.GetTo talMemory(). That number is very different from what Task Manager reports. This is where the problem is, I do not know what caused the OS to allocate that much memory since I am not reallocating any big objects.


      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Runtime and OS report different mem usage

        "Mem Usage" is the same counter as the "Working Set" size, that is the size
        in bytes of the process pages actually mapped to RAM.
        System.GC.GetTo talMemory() only returns the size of the GC heap, which is
        only a part of the WS.

        Without seeing a piece of code it's hard to tell what accounts for this high
        WS usage.

        Willy.

        "Geng Sheng" <anonymous@disc ussions.microso ft.com> wrote in message
        news:AEA6F6D1-BA58-42F7-B08E-D2AF0F269383@mi crosoft.com...[color=blue]
        >I am using Windows Task Manager\Process es by press control-alt-delete then
        >choose "task list". It is a table with the following columns:
        > Image Name, PID, CPU, CPU Time, Mem Usage.
        >
        > I then found the application process name and check the Mem Usage here. By
        > the way, I tried to use PerfMon but I do not know how to enter a specific
        > "Image Name" in those memory counters.
        >
        > On the other hand I am using System.Console to write out
        > System.GC.GetTo talMemory(). That number is very different from what Task
        > Manager reports. This is where the problem is, I do not know what caused
        > the OS to allocate that much memory since I am not reallocating any big
        > objects.'
        >
        >[/color]


        Comment

        Working...