| 05-02-2005, 08:47 PM | #1 |
What is the most efficient way to take all the units within a certain range of a location and add them to a group? I know unit groups can be a major cause of leaking, so I want to avoid all leaking if possible. |
| 05-02-2005, 09:20 PM | #2 |
Well, have you read any tutorials on memory leaks? If not, then here is one made by Cubasis. If yes, then what's the problem anyway? |
| 05-03-2005, 03:06 AM | #3 |
I have been trying to directly add units to a group by doing something like this local group x = CreateGroup() call GroupEnumUnitsInRangeOfLoc (x, SomeLocation, 200, null) However this does not seem to work, so I looked at how blizzard does it, but they end up calling a function that returns a group. If I understand leaking correctly, whenever a function returns a group, it must leak because there is no way to destroy the variable after something is returned. In the end I am fairly confused, so I would just like to know how the pros do it. |
| 05-04-2005, 05:22 PM | #4 |
You don't destroy a variable, you destroy its contents, so the returned groups of GetUnitsIn... functions can be destroyed after that. The local variable will still leak because of not being set to null. The GroupEnum thing should work, err no, IT WORKS, I always use that. After the code you showed here, the x group should have all the units in range of that location. |
