• 🏆 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] [possible leak] strings used in functions

Status
Not open for further replies.

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
JASS:
call DisplayTextToPlayer(GetLocalPlayer(),"This is an example string distributed extensively through the map")

Trying to figure out if strings used like this are re-generated (a new memory allocation) each time the function is called. Do I have to assign a variable or a constant function to deliver this string in order to have it generated only once?
 
Generally, local things leak, but that thing you want displayed is a leak towards the player, not the string itself.
But then, another issue comes on. Players don't need to be nullified, so, you are not leaking in any way. For the "technically" part you read, it's because function parameters don't leak handles, yet objects can leak (unit groups, locations..).

Edit: Hm, just read that DisplayTextToPlayer does leak the string, but the leak cannot be avoided.

Edit2: Yes, strings leak, but there is nothing you can do about it, it's the way Warcraft III functions.
 
In the "memory leak" thread some guys were discussing how strings "technically" leak yet don't leak handles. I don't know what they meant by "technically" :p

I think by "technically" leak is by the fact that they do eat up some bytes, but you can't really avoid it (nor does it really have a noticeable impact). I am not sure how wc3 handles strings though. But I don't think they handle them in the sense that each time upon execution it will create a new string.. Bleh, I don't know though. Aren't they just stored in a table and reused?
 
Oh, how misinformed you are about strings, Pharaoh_. PurgeandFire111, you were right about the table.

Strings leak because every time you make a new string, it is added to the "string table", which means that when you use that string again, it gets it straight from the table so it is faster. There is no way to clear the table, hence strings cause unavoidable leaks.

If you use the same string over and over, however, no new entry is added to the table, it just uses the entry from the first time you used that string. This means that once a certain string has caused the leak once, the same string will never leak again in the same game.

So your answer is no, you do need to save your strings in a constant variable or whatever, it will not help the leaking.
 
Level 9
Joined
Jun 7, 2007
Messages
195
Isn't there a lot of unique strings generated when damage detection systems create flying texts to show damage? (especially if theyre very randomized real values with decimals and the damage values vary a lot, from early game 10-50, slowly towards late game 1000-5000)
Dunno if even that's enough to matter though, but that's a lot more strings comparred to most other cases.
 
Level 8
Joined
Apr 30, 2009
Messages
338
Isn't there a lot of unique strings generated when damage detection systems create flying texts to show damage? (especially if theyre very randomized real values with decimals and the damage values vary a lot, from early game 10-50, slowly towards late game 1000-5000)
Dunno if even that's enough to matter though, but that's a lot more strings comparred to most other cases.

the solution to that is not to put retarded floating text on damage (especially with decimals)
 
Status
Not open for further replies.
Top