SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Should objects be disposed when using the client object model? If so, which ones? There seems to be plenty of information on this for server side, but nothing from Microsoft specifically about client side.

share|improve this question
up vote 8 down vote accepted

There is no need to dispose of objects using the Client Object Model with JavaScript because it handles the memory management for you. For more information on JavaScript memory management check out this article:

share|improve this answer
Should have been more specific - I am curious about all 3 client APIs - but mostly wondering about the .NET Managed Client Object Model. – drquinn Mar 23 '13 at 1:03
None of the APIs require memory management because it must already be handled on the other end to support JavaScript. As you can see in the examples here there is no use of dispose. – Ryan Erickson Mar 23 '13 at 1:06
I noticed that none of the MSDN examples used dispose. Just curious if they left it out for simplicity, but still required for larger operations. Thanks! – drquinn Mar 25 '13 at 18:23
This is incorrect some objects do need disposing due to asynchronous behavior. – Hugh Wood Feb 17 '14 at 9:32

There is no need to dispose of objects in the managed client object model, as there are no unmanaged resources in use, everything is cleaned up by the garbage collector.

share|improve this answer

You do not need to dispose any JavaScript objects. As I understand you are probably asking this question as a part of CSOM using Javascript mostly used in SharePoint apps. I've worked on MSDN code samples and I didn't need to dispose any of the objects. As @ryan has said the garbage collector does the dirty work.

share|improve this answer

For the .NET client object model, the ClientContext object implements IDisposable and you must call Dispose on it when you are finished. It will absolutely cause a memory leak if you do not.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.