• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Things That Leak

Level 13
Joined
Nov 22, 2006
Messages
1,260
Lingonberryjam said:
I cant sort this out still... does these locations leak:
  • Does locations Leak
  • Events
  • Someone answers this
  • Conditions
  • Actions
  • Set Location[4] = (Center of MerchantSpot <gen>)
  • Cinematic - Ping minimap for (All players) at Location[4] for 1.00 seconds, using a Flashy ping of color (30.00%, 100.00%, 100.00%)
  • Unit - Create 1 Elementar Master for Neutral Passive at Location[4] facing Default building facing degrees
  • Custom script: call RemoveLocation( udg_Location[4] )
.
Or do i have to use the custom script removal twice in the trigger?

I don't know why do people who are answering to these kind of threads always ignore the old question and starts answering the new one, but nvm. This won't leak, don't worry. It's important that you understand why: When you store a location in a variable, and you use that variable later, you're always using the same location.

And Lingonberryjam, please pay attention:

Paskovich said:
I don't know how forces leak. All i know is (All players) do NOT leak, and if you destroy it, sthg weird (crash or fatal error?) will happen
 
Level 5
Joined
May 17, 2007
Messages
106
Does
  • Set Temp_TargetPosition48 = (Position of XXX)
  • Set Temp_TargetPosition48 = (Temp_TargetPosition48 offset by 200.00 towards (Facing of XXX) degrees)
  • Do something
  • Custom script: call RemoveLocation(udg_Temp_TargetPosition48)
0 Leak or 1 leak?

oh and does
  • Unit - Create 1 Footman for (Owner of XXX) at Temp_TargetPosition48 facing 0.00 degrees
at (Owner of XXX) is leak or not?
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you destroy (All Players), from then on it'll be equivelant to ForForce'ing 'null'.

Hmmm... I think destroying a unit group renders it unusable, as my spell that uses a unit group only worked once.
...which is why you only destroy the unit group when you're done with it. If you use another Get Units in blahblahblah, it should work fine again until it's destroyed again.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Not if they preexist on the map. (If you initially placed it)

In general:

-IF A VARIABLE IS SET TO AN EXISTING OBJECT then it should not be destroyed
-IF A VARIABLE IS SET TO A FUNCTION then it should be destroyed.

Exceptions;

-Playable Map Area should not be destroyed.
-All Players should not be destroyed.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Nope, actually.

[jass=Explanation]native GetWorldBounds takes nothing returns rect
function GetEntireMapRect takes nothing returns rect
return GetWorldBounds()
endfunction

//vs

function GetPlayableMapRect takes nothing returns rect
return bj_mapInitialPlayableArea
endfunction[/code]

As you can see, Playable Map Area returns a global variable while Entire Map calls a function to create a rect.
 
Level 9
Joined
Jul 24, 2007
Messages
308
errr

OMG, LAST QUESTION, WHY DOES THIS POINT FUCK MY REGION?
  • Set AnotherPoint = (Random point in RegionInPlayableMapArea <gen>)
  • Hero - Instantly revive (Dying unit) at AnotherPoint, Show revival graphics
  • Custom script: call RemoveLocation(udg_AnotherPoint)
RegionInPlayableMapArea is a region existing on map,
on the 2nd use of the point, ITS REMOVED FOR EVER!

edit: and if i use bj_wantdestroygroup, will it remove the unit?
like pick every unit in area and do : order unit to move there, should i use bj_want destroy group here?
 
Last edited:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit group: Pick every unit in (blah) and do (actions)
    • -------- Actions go here --------
Basically, without the custom script it makes a unit variable for every unit in the region, which obviously leaks. Putting the custom script there forces it to remove the unit variable after it's done using it, which does not leak.

Remember, it's case sensitive!
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Actually, bj_wantDestroyGroup is just a global boolean that checks after the ForGroup() function. If it's set to true, then the looped group variable is destroyed. If it's set to false, nothing happens to the group after the loop. It's not the picked units that leak, it's the unit group. You could also create a temp_group variable, set it to Every unit in (blah), then do, Pick every unit in temp_group, and then write this as a custom script.
JASS:
call DestroyGroup(udg_temp_group)
Of course, bj_wantDestroyGroup is alot easier to use, but in some cases, I prefer using temp group variables.

Py, it's impossible to generate global variables, which would leak in this case, but what it does is it gets a return from the GetEnumUnit() function, which returns the picked unit from the looping group. This enum unit is just recycled when you don't need it anymore (after the loop).
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
You need to set it every time you're using it (and destroy it in the end), so:

  • Set AnotherPoint = (Random point in RegionInPlayableMapArea <gen>)
  • Hero - Instantly revive (Dying unit) at AnotherPoint, Show revival graphics
  • Custom script: call RemoveLocation(udg_AnotherPoint)
  • ......
  • Set AnotherPoint = (Random point in RegionInPlayableMapArea <gen>)
  • Hero - Instantly revive (Dying unit) at AnotherPoint, Show revival graphics - I'm using AnotherPoint the second time....
  • Custom script: call RemoveLocation(udg_AnotherPoint)
bj_wantDestroyGroup won't remove the unit, people often think that destroying a group means killing every unit in it, well, it's not like that. It just destroys the variable that hold the units.

EDIT: Wow, even two people were faster.....

like pick every unit in area and do : order unit to move there, should i use bj_want destroy group here?

Yeah, if you don't want any leaks. If you want to keep the group for something else, then do something like this:

  • Set Group = Units in range
  • Unit Group - Pick every unit in Group and do...
  • .....
  • Unit Group - Pick every unit in Group and do...
  • Custom script: call DestroyGroup(udg_Group) - HERE you destroy it
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
i just tried the leak catcher(becouse i cant find a couple of leaks, since i learned about leaks after making a lot of triggers in my map)

when i inserted a trigger with
  • Custom script: call RemoveLocation (udg_Point)
it said that the Point variable wasnt removed

is it wrong with the Leak Catcher or is it the Custom scripts that shouldnt have a Space between RemoveLocation and (udg_Point)?
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Probably you shouldn't put a space.

Why do you use Leak Catcher anyways? Any program like that suck. You'll learn eventually how to find leaks. If you inserted that in your script, it should be destroyed (well it depends on where you've put it).
 
Level 12
Joined
Aug 20, 2007
Messages
866
Custom Scripts

Usually with the triggers i use, i like to put it all in one big array

How would i go about removing something like
Example
PointArray(point_number100)

in custom scripts???
 
Level 12
Joined
Aug 20, 2007
Messages
866
"pointnumber100" being a varying integer

(the 100 i just put in to pretend for a moment that it was set at 100 in the trigger)
 
Level 12
Joined
Aug 20, 2007
Messages
866
I don't know JASS

Just a few custom scripts

I wanted to know what the custom script would be to remove the leak for a variable that has a varying index

Such as a variable
RandomPoint(Custom Value of (Triggering Unit))

Is what it would look like in GUI

I'm wondering how i could remove the leak from a variable using that kind of index
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
when using Custom Value of Triggering unit in a custom script, you must use (GetUnitUserData(GetTriggerUnit()))

and yes, that extra () is necessary

so, here is an example
  • Custom script: call RemoveLocation(udg_Point[(GetUnitUserData(GetTriggerUnit()))])
 
Level 12
Joined
Aug 20, 2007
Messages
866
sorry valkemiere, at the time I had no idea what you ment

You actually ment "Convert Trigger to Custom Script" in the Trigg Editor
At the time you said it, it sounded like you wanted me to convert off the top of my head ><

I got a little frustrated, so I spent the past three days learning JASS

I now know how to get those GUI custom scripts now, thnx for the reply anyways

I think im gonna stop using GUI and start just using JASS, although I can work about 100x faster in GUI, I'm startin' to really get a handle on JASS, which is the only way to do real systems (such as making physics a part of your own WC map)
 
Level 13
Joined
Nov 20, 2006
Messages
553
convert to jass, then copy the variables name,
then ctrl z,
add action,
call removelocation(ctrl+v)

first : cr8 variable for ex: set UnitGroup = bla2
second ; like i said before, convert to jass, then see the
"set UnitGroup = bla2", you copy it ("must be udg_bla2") by press ctrl+c,
then ctrl+z ( to back from Jass trigger to GUI trigger)
last, cr8 custom script : call DestroyGroup("ctrl+V here")

Done!!
 
first : cr8 variable for ex: set UnitGroup = bla2
second ; like i said before, convert to jass, then see the
"set UnitGroup = bla2", you copy it ("must be udg_bla2") by press ctrl+c,
then ctrl+z ( to back from Jass trigger to GUI trigger)
last, cr8 custom script : call DestroyGroup("ctrl+V here")

Done!!

That was so hard to follow.

My eyes are burning.
 
Level 6
Joined
Nov 28, 2007
Messages
203
incase noone knew.. this will leak:
  • Trigger 001
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Hero - Set (Leveling Hero) Hero-level to ((Level of (Leveling Hero)) + 1), Hide level-up graphics
:xxd:
 
Level 6
Joined
Nov 28, 2007
Messages
203
Razorbrain, I know it works for you, it should. Leaks are not whether it's working or not, the full name is memory leaks. It's when (example) you create a special effect at the position of a unit. If that location (the position of unit) is not destroyed, it will stay there and take some memory, so when you create lots of these locations, your map will lag like hell. Imagine it like this, try putting 10000 units on a map and test it, it bet it'll lag because each unit takes some memory, and causes the game to leak. Same for Unit Groups, if you go pick every unit, then WE creates a group so he can do what you said, but if that group isn't destroyed, it will leak.

These are what don't leak: integer, real, boolean, string (in JASS code doesn't leak also)

Blizzard should have made a garbage collector for that, though I'm not sure how that works

http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=27242

get it now :p good explanation.
 
Level 12
Joined
Aug 20, 2007
Messages
866
thanks for clearing that up valkemiere

But I guess I wasn't clear enough, I ment that NOW I understand what JASS is
How to use it
How the functions and variables work

And any natives I would need to know I could get from JASScraft
 
Level 8
Joined
Nov 29, 2007
Messages
371
It's a new point every time. Points aren't stored the same way as strings/boolexprs.

Think units. If you create 2 footmen, are they the same footmen, just because you spawned them both at (Position of (Barracks)) and they have the same stats/type? No, warcraft creates both footmen, not just one.

I'm sorry but I'm a bit of a n00b at this. I have a script which goes like this in my map:

  • Orphan Factory TR
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OrphanCount[1] Less than 20
        • Then - Actions
          • Set OrphanCount[1] = (OrphanCount[1] + 1)
          • Unit - Create 1 Orphan for Neutral Hostile at (Random point in top generator <gen>) facing (Random point in (Playable map area))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OrphanCount[2] Less than 20
        • Then - Actions
          • Set OrphanCount[2] = (OrphanCount[2] + 1)
          • Unit - Create 1 Orphan for Neutral Hostile at (Random point in bottom generator <gen>) facing (Random point in (Playable map area))
        • Else - Actions
Will that leak [don't worry about the variable, I have another trigger that reduces the variable by 1 every time an orphan gets killed]
Or do I have to remove the point(s) every time?

Thanks in advance
DrazharLn

[note: In the map you have to kill orphans for money. Does making/playing this map make me a bad person? :grin:]
[note2: How can you have a problem with killing virtual orphans when you probably spend a lot of time slaughtering equally hapless victims in normal maps [did those creeps do anything to you??? <---- a justification :p]
 
Last edited:
Level 8
Joined
Nov 29, 2007
Messages
371
Thanks verily Silvenon :grin:


[edit] Another question: I've converted my trigger to JASS and find the following:
JASS:
GetRandomLocInRect(gg_rct_bottom_generator)
Should I use
JASS:
call RemoveLocation(udg_LocInRect)
or
JASS:
call RemoveLocation(udg_LocInRect(gg_rct_bottom_generator))

I'm thinking number one because I do not need to remove [or mention] the region too.

I'm also getting
JASS:
GetRandomLocInRect(GetPlayableMapRect())
should I use call RemoveLocation(LocInRect) for this too

[edit 2] how can you check for leaks btw or can you only see the symptoms?
 
Level 5
Joined
Jul 11, 2007
Messages
152
Heres an example of what I have in my map

Actions
Unit - Create 6 Attacker5 for Player 12 (Brown) at (Center of Center Large <gen>) facing Default building facing degrees
Unit Group - Order (Last created unit group) to Attack-Move To (Position of (Random unit from (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to Player 12 (Brown)))))
Wait 45.00 seconds
Set UnitAInt = (UnitAInt + 1)
Trigger - Turn on Spawns2 <gen>
Trigger - Run Spawns2 <gen> (checking conditions)

So this loops around with the other spawning triggers I have in my map where the only thing really changing is the wait time and attacking unit (underlined) with the region changing occasionally (I have 5 spawn points for them)
My map has crashed at least 4 times in a row on bnet at around the same time on my custom timer (about 11 mins in) and I think leaking from
1 unit groups and 2 regions
How can I fix this specifically?
 
Top