MOSS MVP

I've moved my blog to http://blog.falchionconsulting.com!. Please update your links. This blog is no longer in use--you can find all posts and comments at my new blog; I will no longer be posting to this site and comments have been disabled.

Monday, November 5, 2007

SPLimitedWebPartManager.Dispose() bug

I found what I believe to be a bug and figured I’d pass along my findings. If you’re working with the SPLimitedWebPartManager object and call Dispose() on it there’s a minor problem – the Dispose() method does not dispose of the SPWeb object that gets loaded up – if you’re only using one instance this isn’t much of a problem but if you’re doing a lot of looping then you’ll eventually run out of memory on the server.

I have an stsadm command that I created which replaces content within web parts throughout a site – eventually the command fails because there’s not enough memory – I solved my issues by calling manager.Web.Dispose() (where manager is an SPLimitedWebPartManager object) right before calling manager.Dispose(). I also noticed that it doesn’t dispose of the web parts in the SPLimitedWebPartCollection object though this didn’t seem to be causing me any problems but I think it’s because I was already disposing of them when I was finished processing.

No comments: