Results 1 to 4 of 4

Thread: Performance Issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Performance Issue

    My application is taking too much memory while its running even some forms are closed but still forms are not releasing its utilized memory. all this leads to performance issue.

    what method should i adopt so that my form after closing release all its allocated memory. my forms are also using some third party controls like True DBGrid...

    plz help me out...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Performance Issue

    Forms don't need to, and aren't supposed to, release all their memory when they're closed. The .NET Framework provides automatic memory management with a garbage collector that will reclaim memory in a fashion optimal to system usage patterns. You should go to MSDN and read about .NET resource and memory management, but there are two very simple rules that will cover you in 99.99% of situations:

    1. If you no longer need an object and it has a Dispose method or equivalent, call that method.

    2. If you no longer need a reference to an object and the variable will not, or may not, lose scope for some time then set the variable to Nothing.

    That's really all you need.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: Performance Issue

    If you are really worried about it, you can always force the Garbage Collection to happen after a form closes:

    GC.Collect();
    If your problem is solved, please use the Mark Thread As Resolved under Thread Tools!

    Show Appreciation. Rate Posts!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Performance Issue

    Quote Originally Posted by MetalKid
    If you are really worried about it, you can always force the Garbage Collection to happen after a form closes:

    GC.Collect();
    You can but you shouldn't. You shouldn't force garbage collection without a good reason. If you don't know that you have a good reason then you probably don't.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width