Found the following interesting discussion in the Newsgroups:
| Inline or Precedure by:Anonymous | |
| I have Code that can either be run inline or called as multiple procedures. What would be the best practice, I like the component model with procedures but heard that inline executes faster... Thanks in advance... Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing.. Which is faster: dim me as var some code me = nothing or dim me as var some code me.dispose me = nothing Thanks... | |
| Reply: by:steve | |
| in-line code always executes faster that external calls to methods. however, you should *always* design applications for maintainability...very few occasions exist where that model of development will cost your application time. w/o maintainability, you will *always* cost time...your customer's, yours, and will eventually kill your app when it cost more to maintain than the savings it originally afforded. ..net uses non-deterministic garbage collection in order to "know" when it can release resources. setting an object to nothing in .net just helps the gc better tell/determine that the object can no longer be reached/used...and thereby can be killed off. disposing an object makes the gc look at that object in a little different light...it has less to do in order to "know" that no other referencing object can/has access to it. hth, steve "Anthony Nystrom" <anthonynystrom@genetibase.com> wrote in message news:0C7F24FC-E3E8-4E09-B5E2-4EFB23073711@microsoft.com... | I have Code that can either be run inline or called as multiple procedures. What would be the best practice, I like the component model with procedures but heard that inline executes faster... Thanks in advance... | | Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing.. | | Which is faster: | | dim me as var | some code | me = nothing | | or | | dim me as var | some code | me.dispose | me = nothing | | Thanks... | |
| Reply: by:Cor Ligthert | |
| Hi Anthony, Search this newsgroup than you will see that both that you use is called bad code. See above. I hope this helps something Cor | |
| Reply: by:Cor Ligthert | |
| Little addition in the sentence > This can only when there is a dispose method in a class and should than only > be used for unmanaged resources, however that is never for a value. (I placed later that unmanaged resource text in the middle) now the end has to be. A value has never a method, and therefore never a dispose. Cor | |
| Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP]) | |
IMO you should not need to care about that, the JITter is/will be/should be able to do inlining automatically when it makes sense. To your 2nd question: Setting an instance variable to 'Nothing' is different from calling its 'Dispose' method. Calling 'Dispose' will clean up unmanaged resources used by the instance at the time of calling the procedure. -- Herfried K. Wagner [MVP] | |
Posted by Xander Zelders

0 Comments:
Post a Comment
<< Home