Yes, but it's not the Unit/Item that causes the leak, it's the fact that you're creating an object somewhere in the world without using a Point variable to define that "somewhere".
The rule of thumb for Point leaks is this:
If you see the words "
Position of X", "
Center of Region X", "
Random point in Region X", WITHOUT a Variable being Set, know that you're creating a memory leak. Also, when Setting a Point variable, you MUST destroy it before Setting it again, otherwise you will create a leak.
The solution is to Set your own Point variables at these places and then reference those instead:
-
Set Variable MyPoint = (Position of (Triggering unit))
-
Set Variable MyPoint = (Center of Region X)
-
Set Variable MyPoint = (Random point in Region X)
That above trigger actually leaks though, due to us breaking the second part of the rule of thumb about needing to destroy before setting again.
Now it doesn't leak since we're following the rule of thumb:
-
Set Variable MyPoint = (Position of (Triggering unit))
-
Custom script: call RemoveLocation(udg_MyPoint)
-
Set Variable MyPoint = (Center of Region X)
-
Custom script: call RemoveLocation(udg_MyPoint)
-
Set Variable MyPoint = (Random point in Region X)
-
Custom script: call RemoveLocation(udg_MyPoint)
Now how would we apply this to our triggers? Easy, this trigger is completely leak free:
-
Set Variable MyPoint = (Position of (Triggering unit))
-
Unit - Create 1 Footman for Player 1 at MyPoint
-
Custom script: call RemoveLocation(udg_MyPoint)
-
Set Variable MyPoint = (Center of Region X)
-
Item - Create 1 Boots of Speed at MyPoint
-
Custom script: call RemoveLocation(udg_MyPoint)
-
Set Variable MyPoint = (Random point in Region X)
-
Floating Text - Create floating text at MyPoint
-
Custom script: call RemoveLocation(udg_MyPoint)
There's a lot of different things that you can Create at a Point in Warcraft 3, not just Units and Items. You must always follow the rule of thumb for these.
Another important thing to note as some users get confused about this. Sometimes you will Set a Point or Unit Group that you intend to Set ONCE and then use for the rest of the game. In those cases, you don't have to worry about Destroying them because they're intended to exist forever. For example, let's say that there's a Region where your Heroes spawn/respawn at, and this happened multiple times throughout the game. Instead of creating/using/removing a temporary Point again and again at that Region, you could just create a permanent Point there and re-use it forever. In this case the Point would use a unique variable and get Set once and ONLY once, most likely during Map Initialization while everything is still loading.
Maybe this explanation will help you understand why memory leaks are even an issue:
Anytime the game is asking for a location in the world and you aren't referencing a Point variable, the game creates a Point variable for you. This Point variable that it creates is never Destroyed and thus becomes what's known as a memory leak. It's something that will exist forever even though it's no longer needed. That's why you need to take the extra steps to use your own Point variables and manually Destroy them yourself. You're basically throwing away the garbage that Blizzard failed to clean up themselves.