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

[JASS] set whichPlayer = null

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
in this case the null is a waste since players cant leak

but in an other case like this

JASS:
private function Example takes nothing returns nothing
local unit whichUnit = //Something To Get/Create a unit

//Do stuff with the unit

set whichUnit = null
endfunction

If you hadn't nulled the unit you have had a leak everytime you called this function causing the game to take up more memory everytime you call this func
 
Its easy. The variable it refers to is ALWAYS the same.
I agree that you should null it, but some players seem to be really crazy.

Just null all handle locals and you're done. If blizzard changes the way players work (like throwing a new handle everytime a Player() method is called) then you wouldn't have to change the scripts, but the others have. Its also a clearer programming style.

Just don't listen to those guys, they are just being to lazy to do some real programming.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Players cannot be removed anyway, that's right. I'd like to know however how the references are counted. The object knows how many remaining references there are. Is this just an incrementing integer variable (that would overflow sometime) or does it save the variables and thereby demanding dynamic memory volume? Has Blizzard distinguished between unit and player as second does not need to be count?

I agree to the uniform style, though.
 
Level 21
Joined
Mar 19, 2009
Messages
444
Thanks. So I will again nullify all local player variables..

I used to do this, but I read a thread somewhere where it is told it's not needed to nullify player locals.

And, unfortunately, since I removed all lines set playerVariable = null in my map, I get massive leaks the more the game lasts.

That's why I was asking this. I was quite noobish on this :/

Thanks a lot for answers.

So for people having the same question, NULLIFY LOCAL PLAYER VARIABLES. Quite simple, finally :p

Have a good day,
 
This thread fails. There is no leak in nulling player variables or not, same with triggers that never get destroyed or anything that never gets destroyed. If you have a leak in your game, it is not because you didn't null player variables. It's because you didn't shore up your real leaks or optimize your triggers.

Anachron, Blizzard would have to re-code the entire game for Players to not be assigned constant handles. They will never do that for this game. They will likely never patch the world editor again, as well, even though it duly needs it. Nulling local variables is not something which should have to be done, because a better coded language would recognize that the pointers are no longer in scope.
 
Anachron, Blizzard would have to re-code the entire game for Players to not be assigned constant handles. They will never do that for this game. They will likely never patch the world editor again, as well, even though it duly needs it. Nulling local variables is not something which should have to be done, because a better coded language would recognize that the pointers are no longer in scope.
What about fixing the Return bug and adding hashtable? All vJass users had to fix their maps.
 
Level 21
Joined
Mar 19, 2009
Messages
444
Anyway, even if I had some doubts (otherwise I would not make the thread), now they are solved.

Set local player variables to null IS necessary. Otherwise, on massive use like I get in my map, you create a leak. No more, not less.

set Player(integerLocalVariable) = null is useless, but set playerLocalVariable = null is really needed.

Proof? 10 minutes in my map ingame, you get a massive leaks if no player local variables are nullified. 0 leaks when I nullify them.

Edit
Bribe said:
It's because you didn't shore up your real leaks or optimize your triggers.
I think I know how to do triggers dude :p
 
Status
Not open for further replies.
Top