HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Strings leak!?!

09-08-2006, 12:49 PM#1
UnMi
I somehow read everywhere that "strings" are supposed to leak.
Is this true?
09-08-2006, 12:57 PM#2
Rising_Dusk
Quote:
Originally Posted by Weaaddar
I'd like to correct who ever brought up that crazed notion that strings leak.

They don't, they are cached. This is an optimization technique to make string comparisons faster, and to make codeing for gui people easier. Rather then instansiating new strings (and having to worry about them leaking), they are recycled.

Please don't worry about strings, worry about locations and groups. Those are your main leaks. You don't worry that your hero unit leaks do you? Of course not, because they are going to be used all game.

A common string like "Not enough gold." can be used upwards of hundreds of time in a melee game. Why create new ones and sentence them to death by egc (which only runs after the games over or under heavy strained circumstances) when you can keep that same one over and over again.

Quote:
Originally Posted by Vex
Issue is that it caches every string, even those you won't use again so in rare cases you can end up spending way more memory than you should.

This is fixed by changing the way the triggers that make that many strings work.

Of course that's not an alternative most of the times. So I'll recommend people not to care that much about strings.

Search is your friend.
Source Thread