Home ASP.NET.NET interview questions: - Explain the steps to clean unmanaged objects and also maintain its performance?
.NET interview questions: - Explain the steps to clean unmanaged objects and also maintain its performance?
In order to clean unmanaged objects we need to follow the below steps:-
• Implement IDisposable interface and implement the dispose function.
• In Dispose function call the “GC.SuppressFinalize” method.
• At the client side ensure that the “Dispose” function is called when the object is no more required.
Below goes the code, this is also called as “Finalize and Dispose pattern”. This ensures that your objects are created in Generation 0 rather than Generation 1. “GC.SuppressFinalize” tells the garbage collector to not worry about destructor and destroy the objects in the first call itself.
class clsMyClass : IDisposable{~clsMyClass(){// In case the client forgets to call// Dispose , destructor will be invoked forDispose(false);}protected virtual void Dispose(bool disposing){if (disposing){// Free managed objects.}// Free unmanaged objects}public void Dispose(){Dispose(true);// Ensure that the destructor is not calledGC.SuppressFinalize(this);}}Also view following video on estimations of software projects using Function Point Analysis: -
Get more .NET interview questions for preparation.
Regards,
View author’s blog for more .NET interview questions




Write a Comment
All fields marked with * are mandatory
ASP.NET interview questions: - Can you explain Method of Sorting GridViewcontrol in ASP.NET?
Sorting allow you to sort the GridViewcontrol data in Ascending or Descending order.... Read More
By : Shiv Prasad Koirala | Aug 4th, 2011 | ASP.NET
WCF Interview questions:- Which binding do we need to use for WCF REST?
In this article we will show Binding used for WCF REST. For more articles and videos visit us on www.questpond.com... Read More
By : Shiv Prasad Koirala | Nov 16th, 2011 | WCF
.NET interview questions: - Can you elaborate project life cycle?
In this article we will explain about project life cycle. For more articles and videos visit us on http://www.questpond.com/... Read More
By : Shiv Prasad Koirala | Jan 17th, 2012 | .Net
.NET interview questions: - How will you distinguish between ForeGround and BackGround Threading?
threading is a parallel processing unit and helps you to access multiple tasks at a one moment of time.... Read More
By : Shiv Prasad Koirala | Sep 27th, 2011 | ASP.NET
C# interview questions: - Explain anonymous methods in .NET?
n simple words Anonymous Methods means method which are coded inline or methods without method name.... Read More
By : Shiv Prasad Koirala | Aug 5th, 2011 | C#
ASP.NET interview questions: - Can you explain Method of Sorting GridViewcontrol in ASP.NET?
Sorting allow you to sort the GridViewcontrol data in Ascending or Descending order.... Read More
By : Shiv Prasad Koirala | Aug 4th, 2011 | ASP.NET
WCF Interview questions:- Which binding do we need to use for WCF REST?
In this article we will show Binding used for WCF REST. For more articles and videos visit us on www.questpond.com... Read More
By : Shiv Prasad Koirala | Nov 16th, 2011 | WCF
.NET interview questions: - Can you elaborate project life cycle?
In this article we will explain about project life cycle. For more articles and videos visit us on http://www.questpond.com/... Read More
By : Shiv Prasad Koirala | Jan 17th, 2012 | .Net
.NET interview questions: - How will you distinguish between ForeGround and BackGround Threading?
threading is a parallel processing unit and helps you to access multiple tasks at a one moment of time.... Read More
By : Shiv Prasad Koirala | Sep 27th, 2011 | ASP.NET
C# interview questions: - Explain anonymous methods in .NET?
n simple words Anonymous Methods means method which are coded inline or methods without method name.... Read More
By : Shiv Prasad Koirala | Aug 5th, 2011 | C#
Article Categories
YouTube Videos