none
how to reduce the memory of a windows application. RRS feed

  • Question

  • Hello,

    I created an application in vb.net (.Net Framework 4) where i am using window service,WCF, WMI and  Linq.  Also i created a setup of that application and install it on my machine.when i  check on the task manager, it shows 16,744 K memory . at the same time when i install the same setup on virtual machine it shows 34,676 K memory. I am not able to understand why this memory difference is coming on the both machine.

    I want to reduce the memory of my application. Please help me out to get it done.

    Thanks in advance.

    Thursday, May 10, 2012 7:28 AM

Answers

  • Hi,

    there must not be a memory leak. Just the use of some memory is reported and not that the application is using more and more memory over time.

    Just check where you create instances. Maybe you can just keep less data in memory or free it faster so the GC can collect it.

    But in general you should not bother. Your application is using a few MB. If you really want to use less memory, you could consider to not use a managed system like .Net because it will always consume more memory. But again: Why do you care at all?

    If you just want to know why there is a difference between 2 systems:
    - Are you sure that the same is done on both systems?
    - Is .Net configured the same?
    - Check the realy used memory through GC method calls. inTaskManager you only see the memory that Microsoft reserved for the process. It does not show the memory that your application is using. If I should try to find a picture, I would say:
    Imagine that the .Net Runtime is a big box. You just see the size of the big box in Task Manager. But the application is inside the box and it can be quite small.

    With kind regards,

    Konrad


    Thursday, May 10, 2012 1:47 PM
  • In addition to Konrad,

    Use something better than the end user tool taskmanager

    An easy one.

    http://technet.microsoft.com/en-us/sysinternals/bb896653


    Success
    Cor

    Thursday, May 10, 2012 2:06 PM

All replies

  • Hi Sonal  ,

     There my be some input stream or database stream open and not closed after usage .you try to dispose all object that are initialized and no more needed 

    try following article 

    http://esmithy.net/2007/06/25/finding-unmanaged-memory-leaks/

    it may help you 



    Happy Coding Syam.S

    Thursday, May 10, 2012 11:09 AM
  • Hi Syam,

    Thanks for the reply.

    I have tried it but memory is same.

    Thursday, May 10, 2012 1:30 PM
  • Hi,

    there must not be a memory leak. Just the use of some memory is reported and not that the application is using more and more memory over time.

    Just check where you create instances. Maybe you can just keep less data in memory or free it faster so the GC can collect it.

    But in general you should not bother. Your application is using a few MB. If you really want to use less memory, you could consider to not use a managed system like .Net because it will always consume more memory. But again: Why do you care at all?

    If you just want to know why there is a difference between 2 systems:
    - Are you sure that the same is done on both systems?
    - Is .Net configured the same?
    - Check the realy used memory through GC method calls. inTaskManager you only see the memory that Microsoft reserved for the process. It does not show the memory that your application is using. If I should try to find a picture, I would say:
    Imagine that the .Net Runtime is a big box. You just see the size of the big box in Task Manager. But the application is inside the box and it can be quite small.

    With kind regards,

    Konrad


    Thursday, May 10, 2012 1:47 PM
  • In addition to Konrad,

    Use something better than the end user tool taskmanager

    An easy one.

    http://technet.microsoft.com/en-us/sysinternals/bb896653


    Success
    Cor

    Thursday, May 10, 2012 2:06 PM
  • Just a hunch.  Your development machine has a 32bit OS and your VM has a 64bit OS ?


    This signature unintentionally left blank.

    Friday, May 11, 2012 10:05 AM
  • Hello Konrad,

    Good to see you reply.

    well this is a requirement that application should take less memory thats why i care for that. and i have made all the objects and variable nothing after using it. after doing all these things, this application is taking 16,744 K memory.

    Is it taking that much memory because i am using linq, web service or window service or WMI. these technologies takes memory alot?

    i am really confuse what to do. how to reduce it.

    Please help me out.

    Friday, May 11, 2012 10:54 AM
  • Hello Cor,

    Thanks for the reply.

    i downloaded process Explorer on my machine and it showing around 34468 K memory.

    Friday, May 11, 2012 10:56 AM
  • My machine has 64bit OS (window7) and VM has 32 bit OS (xp Professional).
    Friday, May 11, 2012 11:00 AM
  • Well now that's the exact opposite of what I expected.  Typically the x64 version takes up additional memory due to increased size of pointers. (And references are really just pointers with bling)

    One thing you can do is scan your code for objects that are IDisposable and make sure you're using(them) or calling.Dispose() when they're no longer needed.  Otherwise they sit in memory until the GC decides to clean them up.


    This signature unintentionally left blank.

    Friday, May 11, 2012 11:19 AM
  • Hi Nick,

    I disposed all the dataset, datatable and objects. then too its taking this much memory.

    Monday, May 14, 2012 10:29 AM
  • Hi Sonal,

    Just something that came to my mind now: You are using a release build? A debug build used more memory than a release build.

    And did you use a memory profiler? If your application is not using a lot of memory itself, then a lot of resources might even be shared (So DLLs will only be loaded once and Memory isn't really wasted).

    So I would make sure to analyze this much deeper. And I would ask the people why this requirement is important. (So as an example: If they run a SBC environment with 80 sessions on a server, then they might not like 80 * 30 MB used. So a deeper analysis could be good because 25MB base and 5MB per user might be more than ok for them!) So please analyze the requirements in depth and analyze your problem deeper.

    With kind regards,

    Konrad

    Monday, May 14, 2012 11:24 AM
  • Hi, 

    It is difficult to guess what is going on without seeing the application. I would suggest profile the application and see what really taking memory then you can have a call how to deal with?

    for this purpose , one of these can be used

    you can also debug managed program with SOS  http://msdn.microsoft.com/en-us/library/bb190764.aspx

    I hope this helps you...


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    Monday, May 14, 2012 11:27 AM
  • Hi Konrad,

    i am using release build only.

    I have used all the Memory profiler but they are not working.i m fed up with this.

    Tuesday, May 15, 2012 11:21 AM
  • Hi Kris,

    I used Red Date Memory profiler and i made changes in my code using .NET Reflector.

    Its not working for me.

    Tuesday, May 15, 2012 11:23 AM
  • Hi, 

    It is difficult to guess what is going on without seeing the application. I would suggest profile the application and see what really taking memory then you can have a call how to deal with?


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Tuesday, May 22, 2012 8:56 AM
  • Sonal, I think without seeing the application, it's really hard to diagnose your problem. I would advise you to see which action of yours put your maximum resources and you can grab the codebase for it.

    Mark Answered, if it solves your question
    Rohit Arora

    Tuesday, May 22, 2012 10:53 AM