advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Code Around C#'s Using Statement to Release Unmanaged Resources

Find out how to avoid the kind of resource consumption that impedes your application's performance or even stops it from working altogether.  


advertisement
uppose you've obtained unmanaged resources in a class constructor during object construction and the created object was provided to a using statement. However, the resources were not released at the end of the using statement's usage block. Instead, they were released during garbage collection, as you may expect. Sorting through the application's IL code with the DbgCLR debugger, you find that an exception was thrown from the class constructor. So, not only was the object not fully constructed, the Dispose() method was not called when the unmanaged resources were expected to be released. Thus, they were not released and contributed to the resource consumption.


Resource consumption may impede your application's performance metrics or may even prevent it from working at all.


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement