• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Does adding strings together leak?

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
call BJDebugMsg("A"+"B")

Would it leak 3x (A, B, and AB), 2x (A,B) or just 1x (AB) (assuming any of these havent been used earlier)
 
From what I know. No it won't. Wc3 creates those strings at the map initialization with all the other generated objects, and each unique string only needs to get created once. It is created once and then can be used as many times without leak. The thing that might leak if anything(if not destroyed) is the message tag itself not the text.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The question is whether

constant string + constant string, which could possibly be merged in compiler time to a single string, is evaluated together or separately first. I cannot be sure but would assume the latter since jass is just very simplistic and brute.

Anyway, the leak of strings is minor and can be ignored even more in a static context.
 
Of course it leaks. Or at least it stores strings in the RAM and never flushes them. That can be called "leak" in many situations.

Unfortunatly, StringHash cannot be a good test for that (it doesn't return the string's id but really uses an hash algorithm, it seems...).

I'd say like WaterKnight, it leaks 3 times. I don't think it is the 2 times leak and if it only leaks once ("AB"), it may only be working for concatenation of static strings, which is lame.
 
Status
Not open for further replies.
Top