1 / 32

Unmanaged code and SharePoint Internals

sevita
Download Presentation

Unmanaged code and SharePoint Internals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Unmanaged code and SharePoint Internals Karla Ponce Neudesic

    2. Welcome to Houston SharePoint Saturday Please turn off all electronic devices or set them to vibrate. If you must take a phone call, please do so in the hall so as not to disturb others. Thanks to our Platinum Sponsors:

    3. Who is Karla Ponce? Microsoft MVP More than 10 years of experience Active speaker

    4. Agenda Unmanaged code vs. Managed code Why should I care? SharePoint object model Overview SharePoint Internals: SPRequest Common Issues Best Practices Owssvr.dll

    5. Tambien se habla espaol.

    6. Premise SharePoint uses unmanaged code to perform the majority of the work. The managed part of it is much smaller than the unmanaged part.

    7. Unmanaged code vs Managed code

    8. Unmanaged code vs Managed code Managed Code: It compiles to Intermediate Language (IL). It runs and is managed by the CLR. The runtime provides services such as security, memory management, threading, etc. Unmanaged Code: It compiles directly to machine code. It does not run and is not managed by the CLR. It doesn't get the services of the runtime.

    9. Why should I care? For an understanding of how things work: OM is a wrapper of the unmanaged code. The managed part is small; the unmanaged part of is much larger. Understanding will help us to: Troubleshoot issues, fix bugs and do performance tuning. Write scalable, quality and solid code. Avoid memory issues and poor performance.

    10. SharePoint Dlls

    11. Site Architecture and Object Model

    12. SharePoint Internals

    13. Common Issues Potentially excessive number of SPRequest objects (9) currently unreleased on thread 6. Ensure that this object or its parent (such as an SPWeb or SPSite) is being properly disposed. This object is holding on to a separate native heap.

    14. Common Issues An SPRequest object was reclaimed by the garbage collector instead of being explicitly freed. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. Allocation Id: {6E0B2F08-BEE0-43D4-BEDA-FDA2A43F40D8} To determine where this object was allocated, create a registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings. Then create a new DWORD named SPRequestStackTrace with the value 1 under this key.

    15. Unmanaged Code: Best Practices Disposing objects Using objects efficiently Performance concerns Memory allocation Write scalable code

    16. Using objects efficiently Caching Objects that contain an embedded reference toSPWebor SPSite objects. SPWeb and SPSite contain reference to unmanaged code (not thread safety) and should not be cached.

    17. Caching objects and Thread Safety Bad Coding Practice:

    18. Applying a lock:

    19. Good code practice:

    20. Disposing SharePoint Objects Always ensure to correctly dispose all SPWeb and SPSite. Dispose all objects implementing the IDisposable interface . Object disposal: Dispose method; using clause; try, catch, and finally blocks. SPDisposeCheck,free tool that inspects your assemblies for coding practices that cause memory leaks because of improper handling and disposal of SharePoint objects.

    21. Bad coding practice

    22. Good coding practice

    23. Using(SPSite mySite = new SPSite(http://moss) { SPWeb web1= mySite.OpenWeb(); SPWeb web2= mySite.RootWeb(); SPWeb web3 = SPContext.Current.Site.OpenWeb(); }

    24. Performance concerns Memory allocation How many SPRequest objects are open in parallel? Do SPRequest objects still exist at the end of the thread that created it?

    25. SharePoint 2010 Developer Dashboard

    26. Owssvr.dll The principal DLL of the unmanaged code is owssvr.dll OWSSVR.DLL is an ISAPI extension registered in IIS and its methods can be called directly via an HTTP request to /_vti_bin/owssvr.dll. Returning all data for a SharePoint list, including its XSD: http://WebApp/[site]/_vti_bin/owssvr.dll?Cmd=Display&List={ListGuid}&Query=*&XMLDATA=TRUE

    28. Demo

    29. Summary SharePoint executes all the read/write operations to the DB through unmanaged code. SPWeb and SPSite contain a reference to the unmanaged code. Unmanaged objects are created in form of a SPRequest. Because SPRequest does not run under the .NET Runtime, we have to dispose those objects to avoid memory issues.

    30. Q&A

    31. Resources Object Model: http://msdn.microsoft.com/en-us/library/ms430674(v=office.12).aspx Best Practices: Disposing SharePoint Objects http://msdn.microsoft.com/en-us/library/aa973248.aspx URL Protocol: http://msdn.microsoft.com/en-us/library/ms478653.aspx SharePoint Dispose Checker Tool http://code.msdn.microsoft.com/SPDisposeCheck

    32. Session Evaluation Please complete and turn in your Session Evaluation Form so we can improve future events. Presenter: Karla Ponce Session Name: SharePoint Underground

    33. Thanks to our Sponsors

More Related