From My Desktop to the Internet!

Name:
Location: Rowland Heights, California, United States

Tuesday, March 21, 2006

To Dispose or to not Dispose...

For the most part Garbage Collection will run and reclaim memory where objects are no referenced. However, Garbage Collection doesn't reclaim unmanaged resources. Unmanaged resources can be DcConnections, Resources (as in a resources file), any GDI+ Managed and some File IO functionality.Do you absolutely have to call the .Dispose method? No, but you pay a small price in memory loss because the Garbage Collector has to keep the object around a little longer that needed. This is due to the fact that the .Dispose method hasn't been called to clean unmanaged resources. The code that is executed in the Distructor will now have to execute it.If you call the .Dispose method or use the Using Statement the .Dispose method will execute and clean up any unmanaged resources and hints to the Garbage Collector that it no longer has to stay in memory and the memory can then be reclaim on it's next collection.Does every object need to implement IDispose? No, only those that are making use of unmanaged resources or if you sub-class from a class that implements IDispose.Unless you are creating classes that make use of unmanaged resources I wouldn't worry too much about learning how to Implement IDispose - but just in case you wanted to know more here are some links:

http://channel9.msdn.com/ShowPost.aspx?PostID=30187http://www.codeproject.com/csharp/IDispose.asp
http://dotnet247.com/247reference/msgs/44/221574.aspx
http://www.codinghorror.com/blog/archives/000040.html
http://www.thescripts.com/forum/thread229637.html
http://discuss.develop.com/archives/wa.exe?A2=ind0406b&L=dotnet-clr&T=0&O=D&F=&S=&P=3344Otherwise, always call the .Dispose method or use the Using Statement - this is they way to run as lean as possible... Providing the person who implimented IDispose did it correctly.

Wednesday, March 15, 2006

Command Line Tools for Network Interfaces

Everyone knows that when you need to modify your network interface information you have to travel over to the Control Panel and navigate to the Network and right-click on the specific NIC you're interested in. There you can change your network protocols, IP Address, Gateways, etc...

Ever wonder how you would do that if the Control Panel didn't exist?

Check out: netsh.exe

By typing netsh ? it'll guide you through all it's options and command features for modifying the information on you NIC's.