5

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.

3 Answers 3

7

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: https://developer.mozilla.org/en-US/docs/JavaScript/Memory_Management

4
  • Should have been more specific - I am curious about all 3 client APIs - but mostly wondering about the .NET Managed Client Object Model.
    – drquinn
    Commented Mar 23, 2013 at 1:03
  • 1
    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 msdn.microsoft.com/en-us/library/ee857094(v=office.14).aspx there is no use of dispose. Commented Mar 23, 2013 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
    Commented Mar 25, 2013 at 18:23
  • 1
    This is incorrect some objects do need disposing due to asynchronous behavior.
    – Hugh Wood
    Commented Feb 17, 2014 at 9:32
3

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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