• 🏆 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!

removing point leak..which one is the correct way?

Status
Not open for further replies.
Level 3
Joined
Jun 9, 2010
Messages
17
Guys..check out this part of trigger for me

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • TC_Debug[TC] Equal to 1
    • Then - Actions
      • Set TC_Point[6] = (TC_Point[2] offset by 400.00 towards ((Facing of TC_Hero[TC]) + 45.00) degrees)
    • Else - Actions
      • Set TC_Point[6] = (TC_Point[2] offset by 400.00 towards ((Facing of TC_Hero[TC]) - 45.00) degrees)
  • Custom script: call RemoveLocation(udg_TC_Point[6])
and
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • TC_Debug[TC] Equal to 1
    • Then - Actions
      • Set TC_Point[6] = (TC_Point[2] offset by 400.00 towards ((Facing of TC_Hero[TC]) + 45.00) degrees)
      • Custom script: call RemoveLocation(udg_TC_Point[6])
    • Else - Actions
      • Set TC_Point[6] = (TC_Point[2] offset by 400.00 towards ((Facing of TC_Hero[TC]) - 45.00) degrees)
  • Custom script: call RemoveLocation(udg_TC_Point[6])
I think the leak will be removed if I use either way..however when I checked using one of this leak checker, the first one is leak...huhu..
guys enlighten me pls..thx in advance :grin:
 
Last edited by a moderator:
Level 3
Joined
Jun 9, 2010
Messages
17
Actually for the second one, the removing point custom script should be in the 'else' part..not below 'if/then/else'..I wrongly pasted it just now...

Leak checkers are all buggy. Do not use them as they don't detect a lot of things (like the player group leaks in Game - Text Message) and, in this case, tries to detect things that aren't there.

I kinda agree with you dude..just wanted give it a try last night..anyway guys..thanks a lot for the reply..:ogre_haosis:
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
The leak-checker obviously doesn't realize what an if/else block is, which just means it shouldn't be a public resource because that is a really bad bug. Can you please let me know which leak checker you're using and I will ask for it to be removed from our list?

Also, I have a link in my signature "Advanced Triggering Tips" which might teach you how to find leaks on your own without thinking it's some "magical" process that "no human being" could find on his own.
 
Level 3
Joined
Jun 9, 2010
Messages
17
its better for you to know which leaks by urself... ^_^

yes..thats what i did before..just wanna try some of the tools here...hhee:wink:

The leak-checker obviously doesn't realize what an if/else block is, which just means it shouldn't be a public resource because that is a really bad bug. Can you please let me know which leak checker you're using and I will ask for it to be removed from our list?

Also, I have a link in my signature "Advanced Triggering Tips" which might teach you how to find leaks on your own without thinking it's some "magical" process that "no human being" could find on his own.

overall the checker seems ok..but when it comes to if/else block..that is where the problem starts..I use this Leak Checkv3.1 by by Im_On_56k taken from our tool resource.
I read your tutorial before and it is very useful..thank you for that..like I said, i just wanna try this tool and suddenly I became confused when the problem arise...I dont really have so much problem with leaks and I guess maybe my foundation regarding this matter aint so strong...:xxd:
 
Level 5
Joined
Apr 22, 2011
Messages
152
Like

  • Set temp_pos = (Position of (Triggering unit))
  • Set temp_x = (X of (temp_pos))
  • Set temp_y = (Y of (temp_pos))
temp_pos is a "Point" while temp_x and temp_y are "Real"

Also, Pharaoh_ wrote it a post before...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
This why you should use JASS... It is so much clearer to understand why objects leak and also permits far more efficient code.

Basically, every location object you allocate must be deallocated if you do not plan to ever use it again. Once you lose all references to the location before removing it, the location will have leaked and will permantly use up an handle ID and some memory for the object data.

Inorder for the handle ID that the location had to get recycled after deallocating the location object itself, all references to it must be lost. The game does this to make JASS more predictable and prevent stupid errors caused by a variable magically gaining a new valid object which might not even be a matching type. In globals that are used often you do not need to worry about this (variable will be altered sooner or later to premit the index to be recycled) but for globals that are limitedly altered or that may never be altered you need to make sure to null the value after deallocating the pointed object (to prevent a clogged up Handle ID). Also due to a bug with defined locals (not parameter generated locals) you need to null local handles at the end of a function inorder to allow the handle ID an object used to be recycled (it will otherwise forever think the handle ID is still referenced and never allow it to be recycled). Ofcouse objects that never truly get deallocated (such as players) are of no leaking concern and so there is no need to null a variable that points to them ever.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Ofcouse objects that never truly get deallocated (such as players) are of no leaking concern and so there is no need to null a variable that points to them ever.

Actually, the freed memory gained by doing so can be remarkable. I've had an instance where all a guy changed in his script was set a player variable to null and it removed the lag he was getting. It's worth looking into nulling any handle.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
Actually, the freed memory gained by doing so can be remarkable. I've had an instance where all a guy changed in his script was set a player variable to null and it removed the lag he was getting. It's worth looking into nulling any handle.

This does not even make sense I am afraid to say. Nulling a local stops a counter leak. The counter is used to keep track of the number of references to an object, thus it does not actually allocate any memory at all. Infact only if the handle index can be recycled does the counter inaccuracy cause a leak as then it can no longer be recycled meaning that handle index will be permantly blocked.

As players never under go recycling, all it means is the counter is innacurate, not that any memory has leaked. That is unless for some retarded reason the game keeps a list of all reference sources, in which case not nulling a handle would leak but I do not see a reason why it would do that. A simple proof script would be to create a local player pointing at a player 100s of times a second but not null it and see if memory increases. If this really does leak it will make a lot of high up jass people seem rather stupid.

Also leaks do not directly make lag. Lag is caused by total system overload or by net traffic.
 
Status
Not open for further replies.
Top