questions about string leaks

afisakov

You can change this now in User CP.
Reaction score
37
I remember reading in the past that strings kind of leak. That they all get stored in a table that cannot be readily cleared. Trying to get some more information on the issue.
1) Would a line like
JASS:
call DisplayTextToPlayer(udg_player<i>,0,0,&quot;You recieved |cffffcc00&quot;+I2S(goldpay)+&quot;|r interest from &quot;+GetPlayerName(GetOwningPlayer(GetTriggerUnit()))+&quot; for &quot;+GetUnitName(GetTriggerUnit())+&quot; on &quot;+udg_tech_names[i2] )</i>

create a single string that "leaks", or a whole bunch for each instance of "concatenate stringe" being used?
2) Would this use up alot of memory if it runs every time a tower is built in my TD map. or would the net result still be insignificant?

3) Would a line like
JASS:
&quot;You need |cffffcc00 200|r gold to buy a lumber.&quot;
use up additional memory each time it is used, or remember itself? i.e. would it be worthwhile to set it to a string variable at map initialization and then just calling the variable every time? Considering it would run a good 20x per game or so.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
1) Probably one String per concatenation. This is just a guess though.

2) No. A String is very cheap. Even if you build millions of towers (which is quite unlikely) you will probably end up with less then a few MBs.

3) It will probably be better but still, the gain is insignificant. As far as I know strings leak memory because they are stored and re-used if possible. This means any strings that are used only once will leak memory. Strings that are used time and time again will not cost you a dime. (well, not more then is needed anyways)
 

afisakov

You can change this now in User CP.
Reaction score
37
Thanks for the quick reply.
I was worried I would have to reduce it to something like
"You received |cffffcc00"+I2S(goldpay)+"|r interest from tower built"
to cut down on strings generated, but if insignificant I will leave full info in.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top