# Things That Leak

#### johannesr

Level 16
Oh right i didnt notice that.

#### spiwn

Level 12
• Unit Spawn Init
• Events
• Destructible - Gate (Diagonal 1) 3003 <gen> dies
• Conditions
• Actions
• Set Loc[1] = (Center of RunLoc <gen>)
• Set Loc[2] = (Center of Spawn 1 <gen>)
• Set Loc[3] = (Center of Spawn 2 <gen>)
• Set Loc[4] = (Center of Spawn 3 <gen>)
• Set Angle[1] = Angle Between Loc[2] and Position of Gate (Diagonal 1) 3003 <gen>
• Set Angle[2] = Angle Between Loc[3] and Position of Gate (Diagonal 1) 3003 <gen>
• Set Angle[3] = Angle Between Loc[4] and Position of Gate (Diagonal 1) 3003 <gen>
• Trigger - Turn on Unit1 Spawn <gen>
• Trigger - Turn on Unit2 Spawn <gen>
• Unit1 Spawn
• Events
• Time - Every 18.00 seconds of game time
• Conditions
• Actions
• Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[2] facing Angle[1] degrees
• Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
• Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[3] facing Angle[2] degrees
• Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
• Unit - Create 1 Unit1 for Player 12 (Brown) at Loc[4] facing Angle[3] degrees
• Unit - Order (Last created unit) to Attack-Move To (Center of RunLoc <gen>)
Is the correct, not leaking way. If at some point you decide to stop spawning those units, you will not need the locations anymore and thus at that point you should remove the locations.

P.s. I wrote the "Angle Between" out of my head, but there is a function for an angle between locations.

#### LordPerenoldeII

Level 14
how many "pick every unit in group and do action/actions" are required to leak? And what does it do when it leaks? Because i see some trigger not responding after a period i use those functions. Is it because of the leak?

#### Justify

Level 13
No. Leaks increase the memory usage of warcraft, slower computers will start to lagg if this happens. Each of those things leak IF you didn't store the group previously.

#### Saishy

Level 12
But won't it create a location leak every time it spawns a unit there?
- No.

#### Hell13east

Level 4
How do fix the leaks in those 2 examples, i know u do ( call RemoveLocation(udg_Fisherpoint[ ??? ]) ) but well... What should it be in
[ ] section?

• Set Fisher_Point[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
• Set Move_Fish_Here[(Integer A)] = (Curent_Pos[(Integer A)] offset by ((Real(Total_Range_Fishing[(Integer A)])) / 20.00) towards (Real(Degrees_Between_Fish_N_Fisher[(Integer A)])) degrees)

#### Noobsmoke

Level 11
How do fix the leaks in those 2 examples, i know u do ( call RemoveLocation(udg_Fisherpoint[ ??? ]) ) but well... What should it be in
[ ] section?

• Set Fisher_Point[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
• Set Move_Fish_Here[(Integer A)] = (Curent_Pos[(Integer A)] offset by ((Real(Total_Range_Fishing[(Integer A)])) / 20.00) towards (Real(Degrees_Between_Fish_N_Fisher[(Integer A)])) degrees)

I
• Set Fisher_Point[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
Set (Player number of (Owner of (Triggering unit))) as a variable (Exemple :
Temp = Player number of (Owner of (Triggering unit))
Then

( call RemoveLocation(udg_Fisher_Point[Temp]) )

II
• Set Move_Fish_Here[(Integer A)] = (Curent_Pos[(Integer A)] offset by ((Real(Total_Range_Fishing[(Integer A)])) / 20.00) towards (Real(Degrees_Between_Fish_N_Fisher[(Integer A)])) degrees)
( call RemoveLocation(udg_Move_Fish_Here[Integer A]) )

#### Noobsmoke

Level 11
Warning : Is not recommanded to use Integer A in for, replace it with a integer variable ...

#### Hell13east

Level 4
• Set Move_Fish_Here[(Integer A)] = (Curent_Pos[(Integer A)] offset by ((Real(Total_Range_Fishing[(Integer A)])) / 20.00) towards (Real(Degrees_Between_Fish_N_Fisher[(Integer A)])) degrees)
( call RemoveLocation(udg_Move_Fish_Here[Integer A]) )

Uhm.. At least I can't get the ( call RemoveLocation(udg_Move_Fish_Here[Integer A]) to work. sais it expects a name then.

#### Noobsmoke

Level 11
Uhm.. At least I can't get the ( call RemoveLocation(udg_Move_Fish_Here[Integer A]) to work. sais it expects a name then.

do you type the name correctly ?

#### Hell13east

Level 4
Ah, the problem was i had to have [udg_Integer A]

#### Element of Water

Level 17
Ah, the problem was i had to have [udg_Integer A]

That still shouldn't work, because

A) You can't have spaces in variables names -- that should be udg_Integer_A
B) Integer A isn't a "user defined global" (that's what udg stands for), it's this: bj_forLoopAIndex

#### M0RT

Level 12
I have a question about Sound leak. Why do sounds leak when playing? Also, obviosly, by destroying a sound I am unable to use it again.

#### LordPerenoldeII

Level 14
how to destroy music? is it possibile?

#### PurgeandFire

Level 43
I have a question about Sound leak. Why do sounds leak when playing? Also, obviosly, by destroying a sound I am unable to use it again.

They only are really considered a leak if you aren't using it anymore. Basically, if you are using them your entire map (or several times in general) you don't need to remove the sounds. If you perhaps play it once or so, and then you don't need it, then you should kill the sound.

how to destroy music? is it possibile?

You can't, and you don't need to. You can just use Music - Stop Music or whatever it is if you are just trying to stop it. But overall, I don't think music leaks.

#### Bribe

Level 36
Music is not a leak, music is a string. When you do a "play music" call it just tells the game to read the assigned string path. That's solid hardcoding in a game full of loose and wayward objects.

"Leaking" is such a demonizing term for in-game objects. I mean, if you're constantly using `CreateSoundFromLabel`, for example, you need to destroy those. But even if you put 100 sounds in the sound editor and only use each one once, their allocation is so infinitesimal that it doesn't even matter. blizzard.j creates a bunch of sounds and other variables that most users never use, but you don't even notice the difference.

#### M0RT

Level 12
Ok sa basically Sounds are no different from any other objects... so the problem was only the confusing post Thanks for clarification

#### LordPerenoldeII

Level 14
You can't, and you don't need to. You can just use Music - Stop Music or whatever it is if you are just trying to stop it. But overall, I don't think music leaks.

Well, i'd need to, because i have a music(set before but not meant to play all the times) that plays again after another one is finished! I just want that last one to loop. I no more need the first one. :/

#### Berb

Level 17
Music has a very static implementation. There is no way of creating music, and as such there is no way of destroying it. You cannot destroy something that was not created. You could try using `SetMusicPlayPosition` to reset the music, but I don't think they intended on users using music for dynamic sound.

#### White-Lion

Level 7
How do i remove a local location?

#### Bribe

Level 36
From GUI, right? Same as global, but without the udg_ prefix.

Custom script: call RemoveLocation(nameOfLocation)

If you're in JASS you should bang your head against the wall for using locations.

#### White-Lion

Level 7
From GUI, right? Same as global, but without the udg_ prefix.

Custom script: call RemoveLocation(nameOfLocation)

If you're in JASS you should bang your head against the wall for using locations.

Thanks
Well actually i'm using Jass (or atleast trying to learn it), why shouldn't i use location ?

#### Bribe

Level 36
Because locations are avoidable 99.99% of the time -- the only time you use locations is when you need to find the z-coordinate -- and only then.

Use real values (local real x,local real y) instead of locations. Persay, GetUnitLoc should be GetUnitX and GetUnitY.

#### White-Lion

Level 7
okay i'll try this, thank you

#### Raziel_br

Level 11
how to destroy the leak from one Last Created Unit Group?

And for Destructible Group?

Last edited:

#### Bribe

Level 36
Last created unit group does not leak with "last created unit". Also, don't ever destroy "last created unit group".

Destructable groups; there's no such thing.

#### Berb

Level 17
In GUI is `bj_wantDestroyGroup` flagged in the BJ unit-group functions? I suppose I could just open the editor, which I'm doing right now anyways...

Okay, so this is the `ForGroupBJ` function:

JASS:
``````function ForGroupBJ takes group whichGroup, code callback returns nothing
// If the user wants the group destroyed, remember that fact and clear
// the flag, in case it is used again in the callback.
local boolean wantDestroy = bj_wantDestroyGroup
set bj_wantDestroyGroup = false

call ForGroup(whichGroup, callback)

// If the user wants the group destroyed, do so now.
if (wantDestroy) then
call DestroyGroup(whichGroup)
endif
endfunction``````

Now as soon as this is used `bj_wantDestroyGroup` should be flagged as false, which will mean that the next time this function is called it should still remain false. What gives the user control over this (or is it not controllable by the user?). GUI stinks.

#### Raziel_br

Level 11
but how can I do this not in jass?

#### Bribe

Level 36
That "ForGroupBJ" is also known as "Pick Every Unit In Unit Group and Do..."

But you seem to be looking for "Last Created Unit Group"? That's a group that never leaks unless you destroy it (bad move, as it will cease all of your GUI unit creation).

There is a second group that is created if you actually reference the "last created unit group". If you ever use "get last created unit group" you will leak it, unless you set it to a variable and then destroy it. This is because bj_lastCreatedGroup is not equal to bj_groupLastCreatedDest (which ALWAYS leaks).

If I'm wrong, you need to rephrase what you're asking for.

#### Raziel_br

Level 11
no no, you are right, thanks

And to destroy one Doodad Group?

#### Pharaoh_

Level 39
You don't need to destroy doodad groups (I guess you are speaking of the Animation category, because this is the only part you can interact with doodads in-game, right?). There isn't any function to, after all.

#### Bribe

Level 36
Yeah, P is correct, because "Pick every destructable in X" does not generate a "Destructable Group". You can safely use destructable enumeration as often as you can handle it, without a single leak because blizzard was at least smart on that one.

#### Berb

Level 17
Bribe said:
without a single leak because blizzard was at least smart on that one

I would probably have preferred it if both doodad-groups and destructable-groups were both available in-game. It would be nice to at least be able to reference doodads/destructables properly. Doodads are objects in the game that bestow pathing obligations but you can't actually get their exact position, which sucks.

#### gthkeno

Level 4
what is a leak? and what does it do?

#### Berb

Level 17
A leak is a memory allocation that is permanent (until the application is closed).

#### Element of Water

Level 17
And it gradually fills up RAM until the system has to revert to storing "temporary" memory on the hard drive, which slows things down a lot.

#### toofless

Level 8
Leaks slowly strangle your memory until there is no more left and your computer blows up. SO CLEAN YOUR LEAKS OR YOU WILL GET GLASS IN YOUR EYES!

Level 17
ninja'd

#### toofless

Level 8
Hate you

My answer is more accurate though ^^

#### Bribe

Level 36
What the hell? Is this the greatest timing ever in the history of HiveWorkshop? No posts for days and in the same thread in almost the same second you get two posts saying almost the same thing O_O

#### pRo.MAPMAKER

Level 5
Why doesnt this stop the leak..
Custom script: call RemoveLocation(udg_playersbases[udg_Player number of Triggering player])

my original trigger is..

Player - Player 1 (Red) types a chat message containing random as An exact match
Player - Player 2 (Blue) types a chat message containing random as An exact match

((Triggering player) Current lumber) Equal to 100

Unit - Create 1 Heroes[(Random integer number between 1 and 20)] for (Triggering player) at (Center of playersbases[(Player number of (Triggering player))]) facing Default building facing degrees
Custom script: call RemoveLocation(udg_playersbases[udg_Player number of Triggering player])

#### Pharaoh_

Level 39
Make it this way:
• Custom script: call RemoveLocation(udg_playerbases[GetConvertedPlayerId(GetTriggerPlayer())])

#### Berb

Level 17
What the hell is "udg_Player number of Triggering player" supposed to do? I'm sure this just spits out a syntax error for you, am I correct?

For a pro map-maker you sure make nub mistakes. I would read a tutorial on how to use custom script.

#### Tiche3

Level 9
What the hell is "udg_Player number of Triggering player" supposed to do? I'm sure this just spits out a syntax error for you, am I correct?

For a pro map-maker you sure make nub mistakes. I would read a tutorial on how to use custom script.

Ouch berb, don't go like "Hey you mother f****ers!!! GET OVER HERE YOU LITTLE!!" on the poor guy He was just asking some questions.

#### Berb

Level 17
I was slightly joking. I found in ironic that his name was "Pro Map-maker'.

#### pRo.MAPMAKER

Level 5
i don't know everything about the world editor.
Im still learning, but im not exactly noob at it.
Bit ignorant?

#### YourNameHere

Level 11
i don't know everything about the world editor.
Im still learning, but im not exactly noob at it.
Bit ignorant?

pRo.MAPMAKER
i don't know everything about the world editor.
Im still learning, but im not exactly noob at it.

I hope you got the joke, he wasn't serious about it.

[Solved] What's leaking
Replies
10
Views
474
Replies
6
Views
438
Replies
4
Views
380
[Trigger] Removing gui leaks
Replies
0
Views
457
Replies
4
Views
467