none
How to find out why the process is consuming a lot of memory? RRS feed

  • Question

  • Hello.

    I have an application that works as a windows service on the client machine. It is written in C#. All the service does, usually, is asks the server if there are any new tasks for it. It does it once a minute by default. There are basically 2 custom objects that are operating in the app domain. They consist of the timer and a couple of strings. The most "memory heavy" part is probable the proxy class for communicating with the WCF service. Anyway, my application takes up to 30 MB of memory. (determined by task manager or process explorer). I need to know why that is happening? Maybe there are some kind of Visual Studio Plug-in I can use to see what objects take up most of space. What is the technique to address this kind of problem?

    Thanks in advance.

    Max Pavlov
    Wednesday, July 30, 2008 2:16 PM

Answers

  • Is 30mb really a problem?
    Microsoft provides a simple to use and free profiler:
    CLR Profiler
    It shows you what objects use how much memory and and allocation graph and some other useful details.

    hth
    --
    Ben
    bschwehn.de
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Unmarked as answer by Max Pavlov Wednesday, July 30, 2008 3:05 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 3:08 PM
    Wednesday, July 30, 2008 2:34 PM

All replies

  • Is 30mb really a problem?
    Microsoft provides a simple to use and free profiler:
    CLR Profiler
    It shows you what objects use how much memory and and allocation graph and some other useful details.

    hth
    --
    Ben
    bschwehn.de
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:56 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 2:58 PM
    • Unmarked as answer by Max Pavlov Wednesday, July 30, 2008 3:05 PM
    • Marked as answer by Max Pavlov Wednesday, July 30, 2008 3:08 PM
    Wednesday, July 30, 2008 2:34 PM
  • The profiler says <root> element of my service consumes 914 KB, when the task manager says it is 30 MB. I understand that probably the profiler is right and the application doesn't consumes that much of memory, but I will not be able to make a customer believe. It will look like I am trying to trick them and make them think they don't know. The customer is the IT department of the enterprise, and they are very concerned about how much memory does the agent consumes. Maybe there is a way to make it display the "true" consumption like in profiler? Or maybe there is at least an official Microsoft document that will confirm the possibility of such behaver?

    Thanks.

    Max Pavlov
    Wednesday, July 30, 2008 3:02 PM
  • First, in taskmanager don't look at he Working Set Column, but at the Memory(Private Working Set) Column (Column name in Vista, in XP I think this corresponds to "Mem Usage" and "VM Size" resp.). In process explorer, look at the WS Private Column. It more accurately reports the actual memory impact your process has.

    The CLR Profiler shows you only the managed memory usage, your process will use more memory e.g. because it must load the executable image into memory and if your agent is the only process using .net your process is also to "blame" for the additional memory the clr needs to run. Not much you can do about that (other than switching to native code with its own pros and cons).


    --
    Ben
    bschwehn.de
    • Edited by Ben Schwehn Wednesday, July 30, 2008 4:38 PM typo
    Wednesday, July 30, 2008 4:36 PM
  • You can also use the utlility called Process Explorer to see much more detailed memory usage information.

    If you want to delve more into details, like which objects consume more memory, you can save the dump of the process and analyze it in a debugger such as windbg.

    --
    Madhur

    http://blogs.msdn.com/mahuja | Please mark the replies as answers if they help
    Wednesday, July 30, 2008 5:21 PM