SharePoint underground (Unmanaged Code and SharePoint Internals)
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

SharePoint underground (Unmanaged Code and SharePoint Internals)

on

  • 7,606 views

This session covers the unmanaged world of SharePoint. ...

This session covers the unmanaged world of SharePoint.
Internally, most of the things done in SharePoint using either the UI, the object model or web services, are done through unmanaged code. To be more specific: web Parts, web services and other objects in SharePoint are layers over the unmanaged code, and the object model is a wrapper that calls the unmanaged code.

This session explains what is the SharePoint unmanaged code, what are the internals of the unmanaged code and how exactly it works with the object model.

An example on the use of the owssvr.dll (principal dll of the unmanaged code) is also presented.

Some unmanaged code internals are a must know for SharePoint developers.

Understanding how our managed code works, will help us to write better code, troubleshoot, and design solutions in a better way.

Statistics

Views

Total Views
7,606
Views on SlideShare
4,852
Embed Views
2,754

Actions

Likes
0
Downloads
75
Comments
1

6 Embeds 2,754

http://www.sharepointwithattitude.com 2735
http://www.slideshare.net 9
http://translate.googleusercontent.com 6
http://webcache.googleusercontent.com 2
http://twitter.com 1
http://www.slashdocs.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Dispose all objects implementing IDisposable? Don't think so! For instance there's special guidance for RootWeb (never dispose manually). See Roger Lamb's blog for the latest stuff (http://blogs.msdn.com/rogerla/)
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SharePoint underground (Unmanaged Code and SharePoint Internals) Presentation Transcript

  • 1. Unmanaged code and SharePoint Internals
    Karla Ponce
    Neudesic
  • 2. Who is Karla Ponce?
    Microsoft MVP
    More than 10 years of experience
    Active speaker
    I’m not any of that…
    • Twitter - @SPKarlaPonce
    • 3. Blog – http://SharePointWithAttitudecom
  • Unmanaged code vs. Managed code
    Why should I care?
    SharePoint object model Overview
    SharePoint Internals: SPRequest
    Common Issues
    Best Practices
    Owssvr.dll
    Agenda
  • 4. Tambien se habla español.
  • 5. SharePoint uses unmanaged code to perform the majority of the work. The managed part of it is much smaller than the unmanaged part.
    Premise
  • 6. Unmanaged code vs Managed code
  • 7. 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.
    Unmanaged code vs Managed code
  • 8. 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.
    Why should I care?
  • 9. SharePoint Dlls
  • 10. Site Architecture and Object Model
  • 11. SharePoint Internals
  • 12. 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.
    Common Issues
  • 13. 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_MACHINESOFTWAREMicrosoftShared ToolsWeb Server ExtensionsHeapSettings. Then create a new DWORD named SPRequestStackTrace with the value 1 under this key.
    Common Issues
  • 14. Disposing objects
    Using objects efficiently
    Performance concerns – Memory allocation
    Write scalable code
    Unmanaged Code: Best Practices
  • 15. Caching Objects that contain an embedded reference to SPWeb or SPSite objects.
    SPWeb and SPSite contain reference to unmanaged code (not thread safety) and should not be cached.
    Using objects efficiently
  • 16. Bad Coding Practice:
    Caching objects and Thread Safety
  • 17. Applying a lock:
  • 18. Good code practice:
  • 19. 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.
    Disposing SharePoint Objects
  • 20. Bad coding practice
  • 21. Good coding practice
  • 22. Using(SPSite mySite = new SPSite(“http://moss”)
    {
    SPWeb web1= mySite.OpenWeb();
    SPWeb web2= mySite.RootWeb();
    SPWeb web3 = SPContext.Current.Site.OpenWeb();
    }
  • 23. 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?
  • 24. SharePoint 2010 Developer Dashboard
  • 25. 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
    Owssvr.dll
  • 26.
  • 27. Demo
  • 28. 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.
    Summary
  • 29. Q&A
  • 30. 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
    Resources