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

Strings and leaks

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

What's the deal with strings in JASS? From my time on the forums there seems to be a stigma with using/creating strings (dynamically). I believe strings can't be destroyed, so they do cause permanent leaks.

But is that it? If I'm not dynamically generating strings, then there's no other terrible penalty associated with them? i.e. I'm searching a data structure using strings.

This tutorial is lacking in information apparently: http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/complete-list-things-leak-126761/
 
Here is what I think I to remember I've read some time ago:

If you use a string first time it will be saved into the string table and this takes a bit of memory.
When ever you use the exact same string again it will be used of the string table and you don't need more memory for it.

You can not free the table memory anymore, so you can't prevent string leaks. But they are so tiny that you dont have to think about it.
 
All strings that are used will be entered into the string table. There was a rumor a long time ago that the string table will reset at some point, but I never tested it. Anyway, it is indeed a minor leak, but it may be something to consider for games that rely on longevity.

See this for more info:
http://www.hiveworkshop.com/forums/lab-715/documentation-string-type-240473/

As a general rule of thumb, every string is entered into the table. Let's say you have "set s = "hello" + "a" + SubString("hello", 0, 4)". That would generate "hello", "a", "helloa", "hell", and "helloahell" (5 strings in total). If it is already in the table, it won't be entered again (it uses a caching technique so that it won't have to keep generating new strings).
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Problem is if you have some heavy string manipulation functions that spam subbing and concatenation. But for most part you can avoid string work in wc3 triggering. There is no doubt about the existence of the string table but you have yet to show me that desyncing it kills the game.
 
Status
Not open for further replies.
Top