Title of the question is pretty simple, I have 18000 site collections and this script is showing 1GB of ram used, so I wonder how can I dispose correctly the spweb and spsite object  $webapplication =  Get-SPWebApplication  http://xxx foreach($site in $webapplication.Sites) {               foreach($subWeb in $site.AllWebs)     {         if($subWeb.AllProperties["WebTemplate"] -eq "Client" -or $subWeb.AllProperties["WebTemplate"] -eq "Job")         {             if($subWeb.AllProperties["WebTemplate"] -eq "Client")            {                 $infoList  = $subWeb.Lists["Client Info"]            }             if($subWeb.AllProperties["WebTemplate"] -eq "Job")            {                 $infoList  = $subWeb.Lists["Job Info"]            }             if($infoList -ne $null)            {                              $InfoItem = $infoList.Items[0]                if($InfoItem -ne $null)                {                   $clientCode = $InfoItem["Client Code"]                    $quicklaunchnavigationnodes= $subWeb.Navigation.QuickLaunch                   foreach($navNode in $quicklaunchnavigationnodes)                   {                       if($navNode.Title.Contains("Tax Invoices"))                       {                         $clientcodefromurl = $navNode.Url.Substring($navNode.Url.IndexOf("=")+1,8)                          if($clientCode -ne $clientcodefromurl)                         {                             Write-Host 'Processing  site ' $subWeb.Url                              Write-Host '  Info list found for ' $subWeb.Url                              Write-Host '  Info item found '                             Write-Host '    Client code from url: ' $clientcodefromurl                                                       Write-Host '    There is a difference' -ForegroundColor Red                              Write-Host '    Incorrect Navigation Url: ' $navNode.Url                                                        Write-Host '    New Url: ' $navNode.url.Replace($clientcodefromurl, $clientCode)                             #$navNode.url.Replace($clientcodefromurl, $clientCode)                             #$navNode.Update()                             Write-Host '    Url updated' -ForegroundColor Green                          }                       }                                   }                }                else                {                      Write-Host '  Info item not found '$spWeb.Url                 }                       }             else            {                Write-Host 'Info list not found for ' $subWeb.Url             }           }         } }
I have a code that loops through all the Sites and Webs in a web application.  My code uses for..each loop to navigate through each site and web object.  I was wondering if we are required to dispose the SPWeb and SPSite objects when used inside a loop.  Codes:-  foreach (SPSite thisSite in siteAuditWebApplication.Sites) {  //My operation here  }  Similar to the above code I also have some part of code that loops through all the Web and Lists.  Do we have any best practice for disposing objects inside the loop,  or do i really need to take care about disposing the objects?  Thanks in Adv.. Sudhir
ImportError: No module named pkg_resources Make Google stop sending 'new sign in from ...' emails I get at least two emails from Google every time I sign in to my account and I want it to stop.  I tried changing the notification settings in Gmail, but they're still coming and they're useless.  How can I stop this? Adding Image to a Polygon How to compress entire drive C in Windows including locked files? Infinite amount of flags I have been going through some old posts, flagging them as necessary. But I have noticed that the number of posts that I am able to flag is continually staying at ten. It seems that the new flagging system has messed this up.  I am able to keep flagging posts even after 10, so I know it isn't a UI bug. This is a very big problem, because I can flag infinitely many times. And I am pretty sure this isn't the intended behavior of the overlords This isn't because I am being awarded more flags. I flag more than 13 posts in 5 minutes, and I can keep going without restriction  Some of the flags were accepted, so now my number is up to 13. But it is still staying at 13 Uncommitted work pending in unit test with trigger and queueable callout I have an after insert trigger that invokes queueable Apex which makes a callout.  The trigger and callout work fine in the UI and I don't get any errors in normal operation.  However, my unit test keeps failing with the "uncommitted work pending" error despite all my attempts to separate the callout.  I've used a testVisible variable to disable the callout from the trigger so that I can invoke the queueable job explicitly in a startTest/stopTest block after the DML that fires the trigger.  I've pored over the callout class to make sure it's not doing any DML beforehand.  Anyway, if it was doing DML, I should get the uncommitted work pending errors in the UI, right?  I've tried API version 37 and version 41 but the unit test still fails.   I've had a case open with Salesforce premier support for 6 weeks now but haven't made any progress.  Any suggestions?  The unit test:  @isTest static void testCallout() {     // Disable the callout while setting up data.     CCx_EHR_CMCT_Services.isQueueSendEnabled = false;      // Set up the data and execute the DML.     / ...     insert act;      // Set up the http mock     // ...      // Now enable and execute the callout     Test.startTest();     CCx_EHR_CMCT_Services.isQueueSendEnabled = true;     Test.setMock(HttpCalloutMock.class, mock);     System.enqueueJob(new QueueSendToRedox(new List&lt;ActivityHL__c&gt;{act}, desk)));     Test.stopTest();  }   Trigger:  trigger HL_ActivityHL_c on ActivityHL__c (before insert, before update, after insert) {     if (Trigger.isAfter) {         if (Trigger.isInsert) {             CCx_ClientDataDomain.sendEHRClinicalComm(Trigger.new);         }     } }   Trigger handler class:  public without sharing class CCx_ClientDataDomain {     public static void sendEHRClinicalComm(List&lt;ActivityHL__c&gt; triggerNew) {     // do some processing here.     // ...     // then queue the callout job.     System.enqueueJob(new CCx_EHR_CMCT_Services.QueueSendToRedox(             deskActivities.get((Id) desk.getDeskId()), desk));     } }   Queueable job class with callout method:  public with sharing class CCx_EHR_CMCT_Services {     // isQueueSendEnabled is an attempted workaround for unit tests     @testVisible     private static Boolean isQueueSendEnabled = true;      public class QueueSendToRedox implements Queueable, Database.AllowsCallouts {         private List&lt;ActivityHL__c&gt; activities;         private CCx_DeskHierarchySelector.Desk desk;         private Boolean isEnabled;          public QueueSendToRedox(List&lt;ActivityHL__c&gt; activities, CCx_DeskHierarchySelector.Desk desk) {             this.activities = activities;             this.desk = desk;             this.isEnabled = isQueueSendEnabled;         }          public void execute (QueueableContext context) {             if(this.isEnabled) sendClinicalCommToRedox(activities, desk);         }     }      public static void sendClinicalCommToRedox(List&lt;ActivityHL__c&gt; activities, CCx_DeskHierarchySelector.Desk desk) {         // Set up data for the callout.  No DML actions are executed before the callout.         HttpRequest req = buildRequest();         // ...          // Callout         Http http = new Http();         HttpResponse resp = http.send(req);     } } "Error: Invalid signature" when configuring dual boot Ubuntu 14.04 and Windows 10 Eclipse says: “Workspace in use or cannot be created, chose a different one.” How do I unlock a workspace? Why can't Inuzuka clan's dogs use human language? Username and Password not recognized when logging into Minecraft Prove $n!>2^n$ for $n\geq4$ using induction. I just want to know if my proof to this question is correct. First, I proved it was true for $n = 4$. $$4!&gt;2^4$$ $$24&gt;16$$ Then, I assumed that it was true for $n=k$. $$k!&gt;2^k$$ Afterwards, I tried to prove it for $n=k+1$. $$(k+1)!&gt;2^{k+1}$$ $$(k+1)k!&gt;(2)(2^k)$$ Since $k!&gt;2^k$, am I allowed to simply do $$(k+1)(2^k)&gt;(2)(2^k)$$ $$(k+1)&gt;2$$ and this is true for all $k\geq3$. Would the last two steps be illegal because I only assumed that $k!&gt;2^k$ is true? Strategies to Defeat Memory Editors for Cheating - Desktop Games Is exponential map locally a diffeomorphism w.r.t. base point? Let $M$ be a riemannian manifold and $\exp_p: T_pM \rightarrow M$ the exponential map at $p \in M$.  At each point $p\in M$, $\exp_p$ can be restricted to a neighborhood $V$ of $0\in T_pM$ so that $\exp_p|_V$ is a diffeomorphism. Let $U\subset M$ denote image of $V$ under this map.  Choosing an orthonormal basis $\{E_i\}$ for $T_p M$ and using the isomorphism $E: \mathbb R^n \rightarrow T_pM$, where $E(x^1, \dots, x^n)= x^iE_i$, gives normal coordinates $(U, \phi)$, where  $$ \phi := E^{-1} \circ \exp^{-1}_p: U \rightarrow \mathbb R^n $$  My question is: can we fix some $z\in \mathbb R^n$ (small enough) and take some small neighborhood $\widetilde{U}$ of $p$ so that the function $\widetilde \phi$, defined as $$ \widetilde{\phi}_z (p) := \exp_p ( E(z)) $$ is a diffeomorphism when restricted to  $\widetilde{U}$?  (In the definition of $\widetilde \phi$, the isomorphism $E$ will also vary with $p$.) Determining if a game is CPU- or GPU-limited What is a reliable, but not too time-consuming way to determine if a certain game is limited by the graphics card or by the processor speed?  I have some preconceptions about whether I'm mostly GPU or CPU limited, but I'd like to verify if I'm right about that. I have some ideas how I would go around and test that but performing accurate benchmarks is notoriously tricky and I don't have much experience with it.   So I'm wondering what would be an easy way to determine the bottleneck, having only one computer with a certain configuration available? What tools would I use for that purpose?  It would also be interesting to determine if the amount of VRAM on my graphics card is a limiting factor. Kill the [bugs] tag? It seems most of the questions tagged  on Stack Overflow are just intended to indicate "there's something wrong with my program", which would cover probably at least 80% of all questions on Stack Overflow.  There are some questions where it seems to refer to a possible bug in a framework or utility. I'm not sure the tag is really all that useful in that case either.  What does meta think? A map is continuous if and only if for every set, the image of closure is contained in the closure of image As a part of self study, I am trying to prove the following statement:  Suppose $X$ and $Y$ are topological spaces and $f: X \rightarrow Y$ is a map. Then $f$ is continuous if and only if $f(\overline{A})\subseteq \overline{f(A)}$, where $\overline{A}$ denotes the closure of an arbitrary set $A$.   Assuming $f$ is continuous, the result is almost immediate. Perhaps I am missing something obvious, but I have not been able to make progress on the other direction. Could anyone give me a hint which might illuminate the problem for me? Filling in new field in attribute table based on values of another field in ArcGIS Desktop? I have added a new field (Category) in an attribute table of a shapefile and I would like to fill it with numbers, 0 or 1, based on the numbers of another field (Calorific value) of the same attribute table.   That means that if the Calorific value is higher than 15, then I would like to fill in the corresponding cells of the (new) Category field with 1. If the Calorific value is less than 15, then the rest cells of the (new) Category field to be filled in with the number 0.   Is there a way to do this automatically rather than manually? Question  If $|G|=p^3$ and $G$ is not abelian show that $G'=Z(G)$  Attempt   Since $|G|=p^3$ then $G$ is solvable and let $$1\leq G^{(n-1)}\leq...\leq G^{(n)}=G,(1)$$  be its derived series.We know that $G^{(n-1)}$ is an abelian subgroup of $G$ so $|G^{(n-1)}|=p$ or $p^2$ (since $G$ is not abelian).Hence we have that $\bigg|\dfrac{G}{G^{(n-1)}}\bigg|=p$ or $p^2$ so $\dfrac{G}{G^{(n-1)}}$ is abelian $\Rightarrow G'\leq G^{(n-1)}$ so $(1)$ is $1\leq G' \leq G,(2)$.   Furthermore, $Z(G)\not=1$ (since $G$ is a $p-$group) and $\dfrac{G}{Z(G)}$ is abelian $\Rightarrow G'\leq Z(G)$  Is this correct so far? How could I continue? Alright, when I run certain commands the wrong way, (misspelled, etc.) The terminal outputs this: &gt; instead of computername:workingfolder username$, and when I type enter it goes like this:  &gt;  &gt;  &gt;   That would be if I pressed enter 3 times. Imported CSV data is not displayed in QGIS