Is it important to dispose an object in sharepoint ? what is the reason for poor performance.

Sharepoint foundation 2010 and sharepoint server 2010 object model contain objects that implement the IDisposable interface. Object disposal is very important in sharepoint.

Disposing Objects:

Sharepoint foundation 2010 and sharepoint server 2010 object model contain objects that implement the IDisposable interface.
You should explicitly dispose those sharepoint objects that implements IDisposable when you are finished using them.

Why to dispose?

SPSIte and SPWeb class objects are created as managed objects. However, these objects use unmanaged code and memory to perform their work. The manage part of the object is smaller than the unmanaged part.As smaller managed part does not put memory pressure, but large amount of unmanaged code can cause unusual behaviors.

So we should not rely on Garbage collector to release.
How to find incorrect Disposed objects--
--If system performs poor.

--If system crashes or user faces unexpected errors.

If your site is displaying unusual errors, there might be chance of memory leak due to incorrect dispose of objects.

Instance of SPSIte and SPWeb contains a reference to an SPRequest object that in turn contains a reference to unmanaged object.

Comments

Popular

Top 8 C# 6.0 Features

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX

What is Cloud Computing - A guide for beginners