Results 1 to 3 of 3

Thread: GarbageCollector & Unloading Procedures

  1. #1

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    GarbageCollector & Unloading Procedures

    So if anyone has fallowed any of my post, then you will know I'm still in the process of transferring to pure vb.Net, while simultaneously trying to rid any bad habits that stemmed from the good 'ol vb6 days.

    So having said I have a few question that are in regards to the GarbageCollector. Now I'm not looking to modify or mess with it at all, but rather it's exact functionality and where I should be disposing of and handling my own unloading.


    For the sake of my coding style I like to run my application differently than most(unless this is the way it should be done) but this only applies to my more large project...

    So this is how it all begins...
    vbnet Code:
    1. Sub Main()
    2.     Call Loader()
    3.  
    4.     'Here I handle specifics with my main screen form, such as preparing it and setting it up just like you would see in an initialization procedure. Also my scheduler control.  Stuff that didn't quite fit under my Loader procedure above.
    5.  
    6.     'Run the application.
    7.     System.Windows.Forms.Application.EnableVisualStyles()
    8.     System.Windows.Forms.Application.Run(MainScreen)
    9.  
    10.     Call Unloader()
    11. End Sub
    So as you can already guess my startup object is the AppMain sub, and I have the application framework disabled.


    Now my question lies within the Unloader.

    I'm not sure how the GarbageCollecter functions, so truly I'm not sure if my code there is necessary or unnecessary. What it does is unloads all open forms that may have been left behind, plus it closes the database connection if one is open. Also I'm wondering if its a good idea to clear all my collection as well. My concern with the collections is just I have sooo much information being stored(it's a business management system that handles transactions, appointments, inventory clients employees etc etc) and this keeps growing. So I'm not really sure if all this gets handled automatically by the GarbageCollector or if it's good practice to begin clearing out this data and disposing it before hand.




    Thanks in advanced!
    Last edited by DavesChillaxin; Feb 9th, 2012 at 01:04 PM.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: GarbageCollector & Unloading Procedures

    The quick answer is, if you are just using .Net objects, it will be done for you. If you are using images, icons, files, data streams you have a little bit of work to do, but nothing major.

    There are of course pages and pages and pages of documentation written by M$ themselves that explain this fully.

  3. #3

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: GarbageCollector & Unloading Procedures

    Quote Originally Posted by Grimfort View Post
    The quick answer is, if you are just using .Net objects, it will be done for you. If you are using images, icons, files, data streams you have a little bit of work to do, but nothing major.

    There are of course pages and pages and pages of documentation written by M$ themselves that explain this fully.

    Honestly I'm using a little bit of everything.. Though the other stuff you said that does need attention I do handle once I'm done with them of course. Mostly with Using blocks.

    I'll check out these pages too that you have provided, thanks.
    I'm not going to lie here though, but I'm highly self taught. So the way Microsoft words their articles for the most part confuses me... I need examples!
    Last edited by DavesChillaxin; Feb 9th, 2012 at 03:00 PM.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

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