views:

60

answers:

1

We have Best practices on using disposable object in SharePoint.

But i`m thinking - can I skip these when using Console Application? That's some code I want to execute once and after that process has finished. Do or don't SPSite and SPWeb's remain opened somwhere?

Why i`m asking this? I just don't want to stress when using something like

var lists =
  from web in site.AllWebs.Cast<SPWeb>()
  where web is meeting workspace && list is task list
  select list

then do some stuff on lists
etc.

Some serious resource leak there because webs get opened, filtered and NOT closed.

So should I worry in console app?

+3  A: 

Once your command line app terminates, all its resources will be released. After all, the command line app runs in a separate process. This is the same as shutting down IIS, which will also release any resources regardless of the code that forgot to dispose of them.

Joe Capka