Dispose or else suffer

This is really cool thing I got it from my colleage …heres the link.

A few highlights from the same:

1.“If your object has a Dispose method, call it as soon as you are done with the object.”

2.WARNING: Do not write code like this or your hair may fall out, your peers will likely laugh at you, and your code will certainly be suboptimal.


You could also have used simply:

3.Note: you will need to make sure that you build a release optimized version of your assembly (i.e. without debug settings). When the runtime encounters a debug assembly, it intentionally prolongs the lifetime of managed objects through the entire scope of a method call to ease debugging. As a result, the runtime keeps the file open through the entire method, and won’t free it up after it’s last use.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: