Question

So I read through another post here Disposal of SPWebs created using SPSite.OpenWeb().

Currently I only dispose of the SPSite object, and from my understanding whe SPSite disposes any opened SPWeb should dispose as well. It appears best practice is to dispose of each SPWeb as well. I will do so.

My reason for this post is this: what would a memory leak look like? I have a timer job which runs every 2 minutes and processes some list items. Again, i am only disposing of the SPSite object, not the SPWeb object. After letting it run for about a week on dev, the sqlserver.exe process was around 1.7GB of used memory. SharePoint started to error Out of Memory. I have since restarted SQL and it's down to 320MB of memory. I don't know how much it was before I installed the timer job, but we weren't getting these errors then.

Am I seeing a memory leak in sqlserver due to me not closing SPWeb? Or would a SharePoint memory leak occur in the w3wp process? Any clarity is greatly appreciated!

Thanks,

Was it helpful?

Solution

A memory leak will manifest itself in whatever is the host process for the code which has the leak. In the case of SharePoint code, this won't be the SQL process - most likely what you're seeing here is simply down to the fact that SQL generally consumes as much memory as it can (i.e. whatever isn't being scavenged/used by other processes). You can peg it though if you wish, I sometimes do this (e.g. on dev VMs).

So you might see a leak due to SharePoint code in:

  • w3wp.exe for code running from a web page
  • Owstimer.exe for a timer job
  • STSADM.exe for a custom STSADM command
  • The process for a custom exe e.g. in the case of a console app

..etc..

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top