.net not releasing memory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • enggwaqas
    New Member
    • Jun 2007
    • 19

    #1

    .net not releasing memory

    Hi guys,
    I have a memory problem in my vb.net application. It's actually a point of sales system, which must be keep running the whole day.
    The problem is: application is not releasing any memory that it allocates for any resources.
    When my application starts it loads a form say frmLogin, at this time the memory used by my application is for example 67K.
    Now when user enters his credentials an MDI form is loaded, causing memory to increase upto 80K.
    Now even when user closes the MDI form the memory doesnt decrease, between after closing MDI frmLogin is shown.

    I have tried every thing, called .Dispose method, set MDI object to nothing but still of now use.
    One thing i also mention here I am closing frmLogin when MDI is loaded and similary MDI is closed using .Close method after loading frmLoing.
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    Are you having problems wrt to memory consumption? Garbage collection automatically manages memory. You can use dispose method for classes that implement IDisposable.

    Comment

    • bulinckx
      New Member
      • Jan 2012
      • 1

      #3
      GC is automatic and like most automatic things its a litle dumb and sometimes needs a little help.

      I found my app was wasting abou 400MB in memory holding a List<>. To release it I needed:
      1. Explicit clear te object, if it is a list: myList.Clear(); myList = null;
      2. Call the Garbage Collector: GC.Collet();

      In fact most of times objects falls in a "grey area" where the GC cannot guess if it ill be referenced or not.
      Exiting the block of code where myList lives dont free it and calling the GC ill not (immediatly) clean the memory. You must explicit "nullify" the object while inside scope (ie. inside te loop, if or method)! You can call the GC at any time after the object is correctly "nullified" .

      Comment

      Working...