HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can you spot the leak...

08-05-2007, 03:41 AM#1
botanic
ya um lets make a game of it shall we... when you tell it to move it lags till it locks up

Trigger:
Spartan Spearman Create
Collapse Events
Unit - A unit enters pick spartan spearmen <gen>
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Choose your Spartan's class
Collapse Actions
Set Temppoint = (Center of spawn here <gen>)
Set Temp_Unit_Group = (Units in Region 003 <gen>)
Collapse Unit Group - Pick every unit in Temp_Unit_Group and do (Actions)
Collapse Loop - Actions
Unit - Create 1 (Unit-type of (Picked unit)) for (Owner of (Entering unit)) at (Temppoint offset by (0.00, 0.00)) facing 80.00 degrees
Trigger - Add to Hero death <gen> the event (Unit - (Picked unit) Dies)
Set Temp_Unit_Group = (Units in group of spartans <gen>)
Collapse Unit Group - Pick every unit in Temp_Unit_Group and do (Actions)
Collapse Loop - Actions
Unit - Create 1 (Unit-type of (Picked unit)) for (Owner of (Entering unit)) at (Random point in spawn here <gen>) facing 80.00 degrees
Unit Group - Add (Last created unit) to Units[(Player number of (Owner of (Entering unit)))]
Game - Display to (All players) the text: (String((Number of units in Units[1])))
Trigger - Add to deselect <gen> the event (Unit - (Picked unit) Is selected)
Set Player_Units_Number[(Player number of (Owner of (Entering unit)))] = Player_Units_Number[((Player number of (Owner of (Entering unit))) + 1)]
Trigger:
Move
Collapse Events
Unit - A unit Is issued an order targeting a point
Collapse Conditions
((Triggering unit) is A Hero) Equal to True
Collapse Actions
Wait 0.20 game-time seconds
Set Temppoint = (Target point of issued order)
Collapse Unit Group - Pick every unit in Units[(Player number of (Owner of (Triggering unit)))] and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Right-Click Temppoint
Custom script: call RemoveLocation (udg_Temppoint)
08-05-2007, 03:52 AM#2
Tide-Arc Ephemera
In Move, the Unit Group...

In Spartan Spearman Create, the uncleaned point variables! And I think those units will leak points... I haven't used XY coordinates in ages...
08-05-2007, 04:05 AM#3
Ammorth
Random point in region.

Not destroying the group before setting a new one

Offset Location

Not destroying the points in the first trigger



If your hero is in the Units[] group, it will create a loop, that would continually trigger the trigger. Make sure he isn't included, or add a check if the picked unit does not equal the triggering unit.
08-05-2007, 04:51 AM#4
botanic
dollars for doughnuts its the continuous loop that is causing the problem ;P
08-05-2007, 05:25 AM#5
Av3n
Add the units as well to the list

-Av3n
08-05-2007, 06:29 AM#6
Ammorth
Units are not leaks, as long as they can be removed in some way. The reason a point leaks is cause once you lose the pointer, it's impossible to generate a new one. With a unit, you can pick all units in the map and get a new pointer to the unit.
08-05-2007, 06:38 AM#7
MaD[Lion]
hm units do leak.... Its not the unit itself but its the variable... variables take space, and if u dont set them to null they will take big space.

So to make sure nothing leaks... remove/destroy locations, then set these variables to null:
-location (point)
-unit
-player
-force

these are the common variable types that is often use and that leaks.
Remeber GUI leaks alot because off all these GetRandomPointInRegion,Player(1,2,3,4...ect),GetPointWithOffset,AllPlayers()... all these things that you think "give something back" will leak.
so special effects will also leak yes :)
08-05-2007, 06:47 AM#8
DioD
GUI is a one big leak, and its good, you will never meet null handles or other thread crush staff.
08-05-2007, 07:01 AM#9
Tide-Arc Ephemera
Screw that... you can call for custom script! Meh, it's cheating JASS into GUI. I was told something that doesn't exactly crush-- what the hell does crush mean? Desynchronising a player?
08-05-2007, 08:12 AM#10
Ammorth
Quote:
Originally Posted by MaD[Lion]
hm units do leak.... Its not the unit itself but its the variable... variables take space, and if u dont set them to null they will take big space.

Keep in mind the poster is using GUI which only contains global variables (that he could modify). Globals do not need to be set to null since they will be used again later.

Quote:
Originally Posted by MaD[Lion]
these are the common variable types that is often use and that leaks.
Remeber GUI leaks alot because off all these GetRandomPointInRegion,Player(1,2,3,4...ect),GetPointWithOffset,AllPlayers()... all these things that you think "give something back" will leak.
so special effects will also leak yes :)

Using a player as an argument does not leak a player, it calls Player(x) directly. And for when you use Force - Player 1 Red, it returns a bj global, which SHOULD NOT be nulled, or it will never work again.

AllPlayers() does not leak a force either since it returnsbj_FORCE_ALL_PLAYERS which SHOULD NOT be nukked, or it will be "broken" as well.

I don't think the problem is so much the leaking, but the misuse of leak clean-up and not understanding what a leak is. If you are not 100% sure something leaks, don't clean it up. You could end up screwing your entire map up because a force leaked once in a text message.
08-05-2007, 01:38 PM#11
Mr.Wuggles
could someone help me fix it up? botanic was helping me make a "legion" system, but I'm a newb at triggering and I dont really know how to. and for those of you who dont know, it's a unique 300 map im trying to make with botanics' help. but botanic isnt at his computer right now, so... anyone willing to help? I have aim, and if you do too and if you decide to help me, it will probably run smoother.
08-05-2007, 09:35 PM#12
botanic
i understand leaks and such the problem must lie in the creation of an infanate number of points (at least the problem i was trying to fix there)

PS ill fix it tonight Mr.Wuggles
08-06-2007, 01:18 AM#13
MaD[Lion]
Quote:
Originally Posted by Ammorth
Keep in mind the poster is using GUI which only contains global variables (that he could modify). Globals do not need to be set to null since they will be used again later.



Using a player as an argument does not leak a player, it calls Player(x) directly. And for when you use Force - Player 1 Red, it returns a bj global, which SHOULD NOT be nulled, or it will never work again.

AllPlayers() does not leak a force either since it returnsbj_FORCE_ALL_PLAYERS which SHOULD NOT be nukked, or it will be "broken" as well.

I don't think the problem is so much the leaking, but the misuse of leak clean-up and not understanding what a leak is. If you are not 100% sure something leaks, don't clean it up. You could end up screwing your entire map up because a force leaked once in a text message.

PLayer() do leak into a local var
AllPlayers do leak into a local var

Also remember even if a function return a bj variable, it still returns a copy value from that variable, not the referanse... So it will not stop working if u null the returned value ;)
But ofc Player and Forces dont need to be nulled for global vars, but still need to be catched with a globalvariable so that the returned values wont leak.