Custom script: local timerdialog WINDOW
Custom script: local integer HEROWAIT
Custom script: local timer OURTIMER
Custom script: local unit OURHERO
Custom script: set OURHERO = GetDyingUnit()
Custom script: set HEROWAIT = ( GetHeroLevel(OURHERO) * 5 )
Custom script: set OURTIMER = CreateTimer()
Custom script: call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT) ))
Custom script: call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)) )
Custom script: set WINDOW = GetLastCreatedTimerDialogBJ()
Custom script: call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(OURHERO) )
Custom script: call PolledWait( HEROWAIT )
Custom script: call ReviveHeroLoc( OURHERO, GetRectCenter(gg_rct_Sentinel_Start), true )
Custom script: call PanCameraToTimedLocForPlayer( GetOwningPlayer(OURHERO), GetUnitLoc(OURHERO), 0.60 )
Custom script: call DestroyTimerDialog(WINDOW)
I have a question : How can I store a UnitGroup and keeps it without any changes without leaking.
Because I have a trigger like this :
And so i need to keep all of my units in the Unit Group Variable. But it leaks if i don't modify anything and how can i remove this leak without removing the units from the Unit Group ?
Trigger
Events
Temps - Every X.XX seconds of game time
Conditions
Actions
Unit Group - Pick every unit in GroupVar and do (Actions)
Loop - Actions
-------- Actions --------
But he's still dynamic and the unit group changes (add unit in/remove unit from)
PHP:
This doesn't matter as long as you refer to the variable when you add/remove/pick units
kkots said:You can fully control how units are added or removed, except that when a unit dies and decays for too long, then it is removed automatically and the group doesn't have that unit any more in it.
No, they are not removed of the group automatically, but you can't enum them (short story), we call them ghost units : units removed of the game but not of the group.
In the case you don't remove all units using GroupClear or GroupRemoveUnit, or just a GroupEnum... function, you still can clean the group periodically, like using the function GroupRefresh of the vJass library GroupUtils (just as an example)
Theorically there will be a performance issue with a group full of many ghost units comparing to the same group without ghost units, but i don't think that will be ever noticeable in any real case, especially in GUI.
Yes the conditions leak to. The solution is to use an if/then/else (multiple conditions) and do everything in the actions, so that you can destroy the group.
If there were no "conditions", then everyone would just use the if/then/else (multiple conditions) block. They are not really important.
local rect rect_1 = Rect(x-400.,y-400.,x+400.,y+400.)
local rect rect_2 = RectFromCenterSizeBJ(loc, 400.0, 400.0)
local region region_1 = CreateRegion()
RegionAddRect(region_1 , rect_1)
RegionAddRect(region_1 , rect_2)
//...1
RemoveRect(rect_1)
RemoveRect(rect_2)
//...2
Unit, doodads, destructibles and more don't leak. However, if you move a unit to a point and then do something with the unit, the point will leak.I have a question, if a unit dies will it leak? or do i have to remove the unit when it dies?
I will go kill myself. Gimme gun!Units do leak. There is some internal game bug that removing a unit (any means including natural death) does not removal all memory used by a unit. There is no way to avoid this leak next to unit recycling (re-use existing units instead of making more).
Units do leak. There is some internal game bug that removing a unit (any means including natural death) does not removal all memory used by a unit. There is no way to avoid this leak next to unit recycling (re-use existing units instead of making more).
noob here, someone please help. how do i know references from triggers? i've started making some triggers with clearing mem leaks like location with polar offsets and unit groups. here is my map: http://www.hiveworkshop.com/forums/spells-569/8-way-arrowkeys-223047/You don't allocate or deallocate memory yourself. The game allocates memory for objects you create in triggers. The only thing you need to do is destroy the object, so the allocated memory is freed. However you also need to null any local references to destroyed objects because otherwise that specific handle index can't be recycled.
Hello guys!
Credit to: Wolverabid, PurplePoot, Silvenon, Paskovich
I want to make a list of things that leak and ways to fix them.
Dynamic Unit Groups
This trigger will instantly destroy dynamically generated unit groups.
Another way to avoid a group leak is to store the group into a variable, and then destroy it manually.
Trigger
Events
Event
Conditions
Conditions
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Playable Map Area) and do (Unit - Hide (Picked unit))
This is useful if you want to use the group more than once in the trigger.
Set GroupVar = Pick every unit in (Playable Map Area)
Unit Group - Pick every unit in GroupVar and do (Unit - Hide (Picked unit))
Custom script: call DestroyGroup(udg_GroupVar)
Hm, the set bj want destroy group custom script removed the special effect from the group of units.