| 04-21-2007, 08:45 PM | #1 |
Hello everybody, I have a trigger wich makes units spawn all the time. They move to a point and are removed when it's reached. This trigger looks for me perfect but it leaks anyway :/. Please help me. Code:
function Trig_lvl6_Monsters_appear_top_Actions takes nothing returns nothing
local unit troll
local rect regAppear = gg_rct_lvl6_monster_appear_top
local rect regDisappear = gg_rct_lvl6_monster_disappear_down
local real minX = GetRectMinX( regAppear )
local real maxX = GetRectMaxX( regAppear )
local real randomX = GetRandomReal( minX, maxX )
local real appearY = GetRectCenterY( regAppear )
local real disappearY = GetRectCenterY( regDisappear )
local real angle = 270
local integer custVal = 1
set troll = CreateUnit( Player(11), 'n000', randomX, appearY, angle )
call IssuePointOrder( troll, udg_move, randomX, disappearY )//udg_move contains "move"
set troll = null //////////////////
set regAppear = null //to avoid leaks//
set regDisappear = null //////////////////
endfunction
//===========================================================================
function InitTrig_lvl6_Monsters_appear_top takes nothing returns nothing
set gg_trg_lvl6_Monsters_appear_top = CreateTrigger( )
call DisableTrigger( gg_trg_lvl6_Monsters_appear_top )
call TriggerRegisterTimerEventPeriodic( gg_trg_lvl6_Monsters_appear_top, 0.35 )
call TriggerAddAction( gg_trg_lvl6_Monsters_appear_top, function Trig_lvl6_Monsters_appear_top_Actions )
endfunction |
| 04-22-2007, 03:39 AM | #2 | |
Quote:
Well nothing suspicious there besides the fact you are creating a unit each 0.35 seconds, so maybe the issue is with the code that removes the units? |
| 04-22-2007, 08:59 AM | #3 |
I use a variable because when you use a string, it leaks. (it's a little leak but a leak anyway) The string is created, then not removed. This way, it uses allways the same string. This is how they disapear : Code:
lvl6 Monsters from top disappear
Evénements
Unité - A unit enters lvl6 monster disappear down <gen>
Conditions
(Owner of (Triggering unit)) Egal Ã* Joueur 12 (Marron)
Actions
Unité - Remove (Triggering unit) from the game |
| 04-22-2007, 01:05 PM | #4 | |
Quote:
Strings are always created and not removed but "move"=="move" it reuses the same string even if you don't use a variable. -- And well, it doesn't seem to leak, it just lags because of the freaky amount of units to create. I guess you already tried disabling those triggers and the LAG stopped? Also http://www.wc3campaigns.net/misc.php?do=bbcode#trigger and http://www.wc3campaigns.net/misc.php?do=bbcode#jass |
| 04-22-2007, 03:02 PM | #5 | ||
Quote:
How can the computer know that "move" has been used before ? Quote:
|
| 04-22-2007, 03:22 PM | #6 | |
Quote:
... An increase in memory usage is not necessarily a leak. |
| 04-22-2007, 04:12 PM | #7 | |
Quote:
|
| 04-22-2007, 08:28 PM | #8 |
What do you mean by "they just abuse hashes" ? By the way, thx for the links about bbcodes. |
| 04-23-2007, 04:46 AM | #9 |
Every time I do Player(11), doesn't it cause a leak ? Shouldn't I create a local player variable that i set to Player(11), and then set to null at the end of the function ? Here is the new version of my trigger, that still leaks : JASS:function Trig_lvl6_Monsters_appear_top_Actions takes nothing returns boolean local unit troll local rect regAppear = gg_rct_lvl6_monster_appear_top local rect regDisappear = gg_rct_lvl6_monster_disappear_down local real minX = GetRectMinX( regAppear ) local real maxX = GetRectMaxX( regAppear ) local real randomX = GetRandomReal( minX, maxX ) local real appearY = GetRectCenterY( regAppear ) local real disappearY = GetRectCenterY( regDisappear ) local real angle = 270 local integer custVal = 1 local player P12 = Player(11) set troll = CreateUnit( P12, 'n000', randomX, appearY, angle ) call IssuePointOrder( troll, udg_move, randomX, disappearY ) set troll = null set regAppear = null set regDisappear = null set P12 = null return false endfunction //=========================================================================== function InitTrig_lvl6_Monsters_appear_top takes nothing returns nothing set gg_trg_lvl6_Monsters_appear_top = CreateTrigger( ) call DisableTrigger( gg_trg_lvl6_Monsters_appear_top ) call TriggerRegisterTimerEventPeriodic( gg_trg_lvl6_Monsters_appear_top, 0.35 ) call TriggerAddCondition( gg_trg_lvl6_Monsters_appear_top, Condition(function Trig_lvl6_Monsters_appear_top_Actions )) endfunction |
| 04-23-2007, 08:25 AM | #10 |
ok the time is here to open your eyes =) there is no serious problems with our code ! the problem is what war3 does not clear fully unit's from memory thats all =) so it will need more and more and more and more memory =) but the leaks are not so great so you can ignore it... // you can test it for example with trigger like this but with a less period... (use SetUnitPathing(unit,false)) |
| 04-23-2007, 08:30 PM | #11 |
It's quite a big problem -.- Is there no way to remove units totally ? What is SetUnitPathing for ? |
| 04-23-2007, 08:49 PM | #12 | |
Quote:
Vex may say it's not true but it's true ! =) |
