• 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.

What and How do Strings Leak?

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
So I've heard somewhere that strings leak, but I'm not sure of the details.

Do any of these leak:

  • Set TalkSystem[1]= Hello Ryu
  • Game - Display to (All players) for 30.00 seconds the text: Hello Ryu
  • Game - Display to (All players) for 30.00 seconds the text: TalkSystem[1]
  • Floating Text - Create floating text that reads 129 above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
  • Floating Text - Show (Last created floating text) for (All players)
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
If not, what leaks then?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Every new string (a unique character set, set defined as a group or collection of something) you generate is stored on a internal string table that is unreachable by jass script. I wouldn't call that a leak though, it's a feature(optimal memory management maybe?). Purge has more details, you could ask him.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Basically, every time you create a string that has a unique set of characters it will leak. (Note : These types of leaks are smaller than other leaks in terms of memory usage)

So if you do

Set Variable = "Hello"
Set Variable2 = "Hello"

it will only create one string leak. The reason why its leaking is that all strings in wc3 are simply pointers to the global string table. If you declare a new string, than it has to add the new string to the table if it doesn't exist. These leaks can't be cleared. In general, don't worry about it unless your processing custom chunks of strings
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I wouldn't call that a leak since the retention of strings are intentional, it's better than allocating memory every time you use a single string multiple times.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I wouldn't call that a leak since the retention of strings are intentional, it's better than allocating memory every time you use a single string multiple times.

Meh. Interpreting the definition of leak as "something user-created, takes memory, and cannot be removed"
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Ok thanks for your replies. Since there's no way of clearing the leaks, is it something to worry about?

I have a string set for each character in my game. By the time I finish my game, there may be a few hundred characters. Each character may have his variable string changed 2-3 times on average.

So basically. I might have 600-900 string leaks by the end of this game. How major is this? My talk system is pretty imperative for my map to work the way I want it.
 
For more info:
http://www.hiveworkshop.com/forums/lab-715/documentation-string-type-240473/

It isn't necessarily a "leak"--conventionally a leak in wc3 is memory that is no longer needed and can no longer be referenced--but that is just semantics and doesn't really help much. :p edit: Although different people have different definitions (I posted this before reading arhowk's post #5).

The key thing to note is that a line like this:
  • Game - Display to (All players) for 30.00 seconds the text: Hello Ryu
Only stores the string once. Even if you display it 10,000 times, it will not take up any more memory in the string table. The only strings you might want to worry about are ones that return different values very often. For example, a game timer that records seconds and milliseconds and puts it as text in a multiboard. That would be 100 unique strings per second, and it would reach 10,000 unique string entries after 100 seconds (1 minute, 40 seconds).

There was some claim that the string table will reset after a certain point, but that hasn't been confirmed (it is kind of difficult to confirm unless you down-patch to a patch before 1.24).

EDIT: 600-900 strings is insignificant. You probably won't need to worry until you get to a scale of tens of thousands of strings.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Try to limit string concatenation on dynamic strings, or usage of dynamic strings, but not avoid it.
 
Status
Not open for further replies.
Top