And,why are leaks bad anyway? will my map become bad if there is a leak?
Wc3 objects (i.e. handles) use memory and only will deallocate it when being destroyed by the map maker. Look at
Things That Leak for a very good overview.
Only a limited amount of memory is available and performance will suffer with an increasing amount. Mind though that only
thousands of leaks will really affect performance.
Having a leak means having memory allocated which
a) should no longer be allocated because it will not be used again
b) can't be deallocated because there is no reference to it left
Lets look at an easy example:
-
Unit - Move (Triggering unit) instantly to (Point(0.00, 0.00))
translates to following JASS
JASS:
call SetUnitPositionLoc( GetTriggerUnit(), Location(0, 0) )
The function Location(real x, real y) will return a location, which is a handle occupying memory. It will still be in memory, unaccessible, after the execution of the trigger and therefore be a leak. On the next execution a new location will be created and again sit in memory.
Now imagine this trigger executed once every 0.01 seconds. Thats 100 more leaks per second. After some minutes, you would certainly notice a difference in a frames per second drop resulting in stuttering.
To not let the leak happen, a solution in GUI would be to assign the location to a variable, use it, and then remove it with the correct custom script JASS function, like this:
-
Set myLocation = (Point(0.00, 0.00))
-
Unit - Move (Triggering unit) instantly to myLocation
-
Custom script: call RemoveLocation(udg_myLocation)