views:

1162

answers:

3

Hi all, I need to create feature which will iterate through all subsites of site collection and add some sample content to each of them (sample content=new pages,images,documents,possibly some lists). There is solution that uses recursion to loop through sites (it can be found here).

So i'm asking:

  1. Did any of you implemented something similar, maybe in different way?
  2. What was the performance of such iteration?

I can't really say how many subsites can be present in site collection, since this feature should be used in more projects. But i guess the number of subsites shouldn't excess 100 or such.

+2  A: 

That is a very common method of performing looping of sites and web parts.

Speed with 100 sub-sites will not be a problem. It is really quick, if you do alot of processing that can slow it down.

The one thing to watch is the disposal of items if you leave the open or don't close you can suck all the memory from the WFE, especially if alot of users reload the page at the same time. See http://www.sharepointnutsandbolts.com/2008/06/disposing-sharepoint-objects-what-they.html and http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx for examples they also have the disposal tool at http://blogs.msdn.com/sharepoint/archive/2008/11/12/announcing-spdisposecheck-tool-for-sharepoint-developers.aspx

Will Dieterich
Thanks for useful links. I'm maybe a bit paranoid about SP performance :)
drax
just a nitpick: disposing frees up resources (such as db connections), not memory.
vitule
A: 

You can look at the answer I gave to this question. I think I've used the correct dispose patterns for that piece of code.

LeonZandman
A: 

If you need to do a read-only loop through a big structure, here's a cool, yet a bit untraditional, way of doing it:

http://hristopavlov.wordpress.com/2008/10/20/a-very-fast-method-to-get-the-site-collections-web-structure/

anchorpoint