Solved

Memory Utilization Problem in .NET

Posted on 2004-11-01
155 Views
Last Modified: 2010-04-24
Dear Experts,

According to .net documentation, Garbage Collector should free the memory. we analysed and found following things.

1- We have 40 modules in window desktop application in VB.net. Every module opening adds 1 or 2 MB to Memory utilization statistics displayed in Task Manager. Now see, a user was engaged in public sector dealing. He has to open forms 100 times a day and has to perform different tasks. Continuous addition to memory causes application to become slower. User has to shutdown Application and then restarts if he needs to free Memory which is not acceptable.  

Please Advice...we have tried to destroy objects explicitly and we have call system.GC.Collect also with that.......but no improvement

Regards,
Fahim
0
Question by:fahimnxb
    10 Comments
     
    LVL 10

    Accepted Solution

    by:

    Destroy all the objects
    Clear the content in treeview befor destroy it
    if you have image lists clear the images before destroy it
    If you have webbrowser control navigate it to "about:blank" and destroy it

    After destroy all the objects
    call
    GC.Collect()
    GC.WaitForPendingFinalizers()

    Regards
    Prakash
    0
     
    LVL 10

    Expert Comment

    by:prakash_prk
    http://www.scitech.se/memprofiler/Default.htm

    Try this memory profiles to find the leaks, unremoved instanes .

    Regards
    Prakash

    0
     
    LVL 8

    Assisted Solution

    by:wguerram
    Do you have public varaibles?

    If there is an reference to the an object the GC won't collect the memory.

    What type of application is yours? do you play alot with images? data?
    0
     
    LVL 12

    Assisted Solution

    by:farsight
    [nitpick]

    >  Continuous addition to memory causes application to become slower

    To me, this sounds like a conclusion rather than a fact.
    Investigate what leads you to believe that additional memory used by your application is the CAUSE of it becoming slower.
    0
     
    LVL 5

    Author Comment

    by:fahimnxb
    Ya data loaded in memory is too large, after destroying all objects , data sets adapter etc. And also calling
    GC.Collect()
    GC.WaitForPendingFinalizers()
    memory is not recovered.

    Eg
    used memory before execution 100Mb
    used memory after execution 450Mb
    used memory after destroying all objects 350MB

    dats the story.

    Regards,
    me

    0
     
    LVL 10

    Expert Comment

    by:prakash_prk

    can you say which types of objects you have in your project ?

    full objects list ?
    0
     
    LVL 12

    Expert Comment

    by:farsight
    That's really not a problem.

    GC.Collect is like cleaning your house.  It moves everything to the proper place, but it doesn't make your house smaller.
    To get your house smaller, .NET will release some of your application's memory when the system becomes memory constrained.  But it there's plenty of memory, it will leave your house (your application) large.
    0
     
    LVL 8

    Expert Comment

    by:wguerram
    But something is not good, since this is causing the application become slow.
    0
     
    LVL 5

    Author Comment

    by:fahimnxb
    Exactly application is getting slow and GC.Collect is not collecting memory properly.

    Objects are DataAdapter, SqlConnection, DataSet etc.


    Regards,
    Me
    0
     
    LVL 8

    Expert Comment

    by:wguerram
    What version of visual studio are you using?

    are you closing the connections when the forms are being closed or disposed?

    how many forms do you have in your application?

    have you noticed if an specific form that is causing the problem or all the forms cause the problem?
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Datagrid 6 10
    VB.Net and XML XSD Files 1 27
    String.IsNullOrEmpty in asp.net vb,net question 1 22
    Converting string to currency 10 25
    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now