Passing SharePoint objects as arguments to a function. This is bad?

I am creating a web part that includes a function with an SPList as one argument. The skipped list will grow over time, which makes me worry about the scalability issue. Should I be worried about potential performance issues using this method?

If you can offer any insight into other SharePoint objects (SPSite, etc.) related to my question, or provide a link to further reading on this topic, I'd really appreciate it!

0


a source to share


3 answers


Why would this be a problem? Do you expect the data in the list to be copied when you call the function? It will not happen. SPList is a reference to an SPList object and you only copy the reference.



Otherwise, I can't figure out why the scalability issue occurs. Please indicate why you think there may be one.

+2


a source


If you need performance information with SharePoint objects, you should read about recycling SPSite and SPWeb. Every SharePoint developer should be aware of this.



http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx

+2


a source


To add to John Saunders answer, objects like SPList don't actually create a list of all this data in memory when instantiated. Rather, it creates a connection to where the list data is stored in the database, and any calls to that object run its own SQL on the backend. Essentially, the SPList object is a link. Passing it as a parameter is ok!

+1


a source







All Articles