If you can't read please download the document
Upload
sharepoint-saturday-ny
View
811
Download
4
Embed Size (px)
Citation preview
2. About me
3. Working with SharePoint since SP 2003 4. Work for Liquid Hub 5. User Group speaker 6. Overview
7. No more destructors 8. SPSite and SPWeb not always disposed 9. Leaves growing used memory block 10. Leads to problems 11. Memory Usage
12. Application Pool limitations 13. 64 bit vs 32 bit 14. Restaurant Analogy
15. Memory is reserved in chunks like number of diners 16. Memory wants to sit together 17. Memory Leaks
18. SPSite and SPWeb sites have ~2kB size wrappers 19. Object sizes are closer to 1-2 MB 20. One site with 15 webs accessed twice has used around 30 MB of system memory; for *one* user 21. Can bring down entire farms 22. Running in Debug mode 23. /3 GB switch Doesn't work in SharePoint! 24. Example 1 public void GetNavigationInfo() { SPWeb OurWeb = http://intranet.litwareinc.com; foreach( SPWeb OurWebinOurWeb .GetSubWebsForCurrentUser()) { //Our Subsite code here} } 25. Memory Danger Signs
Does the system perform poorly under heavy loads? 26. Does the entire system crash or users receive Page not available? 27. Does the system use custom webparts or third party webparts? 28. Are you running multiple applications from the same app pool? 29. Does the ULS log state Potentially excessive number of SPRequest threads currently unreleased? 30. Was any compiled code released in debug mode? 31. Example 2 public void GetNavigationInfo() { SPWeb OurWeb= http://intranet.litwareinc.com; foreach( SPWeb OurWebin OurWeb.GetSubWebsForCurrentUser()) { //Our Subsite code here OurWeb.Dispose(); } } 32. Example 3 pt 1 try { SPSite OurSiteObject; SPWeb OurObject; //our main code body here } 33. Example 3 pt 2 catch { //Our exception handling code } 34. Example 3 pt 3 finally { if(OurObject != NULL) { OurObject.Dispose(); } if(OurSiteObject != NULL) { OurSiteObject.Dispose(); } } 35. Breakdown
36. Finally block executes the dispose after the code block is complete to avoid problems 37. No explicit calls to dispose necessary for SPContext initializations* 38. Using statements
39. Single block usage with automatic disposal 40. No additional call out to the dispose method is needed 41. Cannot use method outbound transfer of object beyond the using block 42. Example 4
43. //Our Code Here; 44. } 45. Caching
46. Improves access time 47. Is not thread-safe
Best for single-user applications 48. Example 5
49. { 50. SPListItemCollection oListItems; 51. oListItems = (SPListItemCollection)Cache["ListItemCacheName"]; 52. if(oListItems == null) 53. { 54. oListItems = DoQueryToReturnItems(); 55. Cache.Add("ListItemCacheName", oListItems, ..); 56. } 57. } 58. Example 6
59. { 60. DataTable oDataTable; 61. SPListItemCollection oListItems; 62. lock(this) 63. { 64. oDataTable = (DataTable)Cache["ListItemCacheName"]; 65. if(oDataTable == null) 66. { 67. oListItems = DoQueryToReturnItems(); 68. oDataTable = oListItems.GetDataTable(); 69. Cache.Add("ListItemCacheName", oDataTable, ..); 70. } 71. } 72. Scalability
73. Even with proper dispose, memory can grow 74. Projected concurrent users are a factor in your design 75. Size of farm employed to host 76. Scale Questions Pt 1
77. Is the data the same for all users or does it change?(Dependent on user account, department within the company, etc) 78. Is the data easily accessible or does it require a long time to return the data? 79. Scale Questions Pt 2
80. What is the size of the data? 81. Is the SharePoint site on a single server or on a server farm? 82. Links
83. Memory Pressure in MOSS:http://blogs.technet.com/stefan_gossner/archive/2007/11/26/dealing-with-memory-pressure-problems-in-moss-wss.aspx 84. Memory leak checking tool :http://blogs.msdn.com/b/rogerla/archive/2009/01/29/automate-sharepoint-dispose-code-reviews-with-spdisposecheck.aspx 85. Memory Explained; The restaurant analogy:http://blogs.msdn.com/b/tess/archive/2006/09/06/net-memory-usage-a-restaurant-analogy.aspx 86. 87. 88. Questions?