Here's some information regarding how triggers work and how everything is executed.
So take this trigger setup for example. After 1.00 second I create 10 Footman. This leads you to believe that all 10 footman are created at the same time, however, this isn't really the case. In actuality the Footman will be created 1 at a time until all 10 created.
-
Create
-

Events
-


Time - Elapsed game time is 1.00 seconds
-

Conditions
-

Actions
-


Set Variable Point = (Center of (Playable map area))
-


Unit - Create 10 Footman for Player 1 (Red) at Point facing Default building facing degrees
-


Custom script: call RemoveLocation (udg_Point)
This 1 at a time order is important because say for instance you had another trigger like this:
-
Enter Map
-

Events
-


Unit - A unit enters (Playable map area)
-

Conditions
-

Actions
-


Game - Display to (All players) for 30.00 seconds the text: A Unit Entered The Map
If all 10 footman were created at once then how would this trigger know which unit entered the map? Which of the 10 footman would be considered the entering unit? But that's not a problem since each Footman spawns 1 by 1, meaning that this Event will happen 10 times, once for each Footman.
So regarding your comment about tempLoc and what happens if a lot of units die, understand that each unit will die 1 by 1 meaning that a trigger like this will happen once for each dying unit:
-
Unit Dies
-

Events
-

Conditions
-

Actions
-


Game - Display to (All players) for 30.00 seconds the text: A Unit Died
So if you set tempLoc in this Unit Dies trigger, it would get created once for each dying unit (so 10 times if our Footman died). So if we killed our 10 Footman then tempLoc would be set 10 times, and if you didn't remove tempLoc each time then you've leaked the first 9 of those tempLoc variables. The reason you haven't technically leaked the 10th (most recent) tempLoc is because you can still use "call RemoveLocation (udg_tempLoc)" to get rid of it.
Another important thing to understand:
Triggers, similar to actions, are executed in a certain order and certain number of times. If an Action in a trigger were to cause the Event of another trigger to go off, like how creating a unit sets off the "A unit enters map" Event, then the "A unit enters map" trigger's actions would actually be added onto the current trigger.
Here is that concept in action:
This is our Create trigger.
-
Create
-

Events
-


Time - Elapsed game time is 1.00 seconds
-

Conditions
-

Actions
-


Set Variable Point = (Center of (Playable map area))
-


Unit - Create 1 Footman for Player 1 (Red) at Point facing Default building facing degrees
-


Custom script: call RemoveLocation (udg_Point)
This is our Enter Map trigger.
-
Enter Map
-

Events
-


Unit - A unit enters (Playable map area)
-

Conditions
-

Actions
-


Set Variable Point = (Random point in (Playable map area))
-


Special Effect - Create a special effect at Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call RemoveLocation (udg_Point)
This is how our Create trigger actually works. The Actions from Enter Map are added onto the Create trigger:
-
Create
-

Events
-


Time - Elapsed game time is 1.00 seconds
-

Conditions
-

Actions
-


Set Variable Point = (Center of (Playable map area))
-


Unit - Create 1 Footman for Player 1 (Red) at Point facing Default building facing degrees
-


Set Variable Point = (Random point in (Playable map area))
-


Special Effect - Create a special effect at Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call RemoveLocation (udg_Point)
-


Custom script: call RemoveLocation (udg_Point)
So that's clearly a problem. Notice how the Actions from Enter Map shove their way into our Create trigger, happening immediately after the Footman is created. Because of this our first Point variable will never get removed because the Point from Enter Map is replacing it. This replacement effect creates a memory leak because we've lost reference to our first Point. A solution to a situation like this is to use unique variables, that way we can set them apart.
If we used different Point variables in both our Create trigger and our Enter Map trigger, we could end up with a leakless result like this:
-
Create
-

Events
-


Time - Elapsed game time is 1.00 seconds
-

Conditions
-

Actions
-


Set Variable Point1 = (Center of (Playable map area))
-


Unit - Create 1 Footman for Player 1 (Red) at Point1 facing Default building facing degrees
-


Set Variable Point2 = (Random point in (Playable map area))
-


Special Effect - Create a special effect at Point2 using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call RemoveLocation (udg_Point2)
-


Custom script: call RemoveLocation (udg_Point1)
With that being said, having a single Point variable like tempLoc still comes in handy. There are plenty of situations where a triggers Actions DON'T set off another Event, so in those cases you can freely use tempLoc knowing that the situation above won't happen.