HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What about string leaks (with timers and game cache)?

02-11-2007, 04:47 AM#1
CaptainPicard
Question concerning string leaks, timers, game cache...

I've been finding the game cache quite useful, along with Blade.dk's stomp spell tutorial. I've produced a number of decent spells, with precise timing.

Take the example of the Stomp Spell that Blade.dk made. It seems that, if JASS strings leak, the 4-byte strings he's allocating will amount to a sizeable memory leak with each execution of the spell. Some of my spells, with long-timescale effects at 0.04 second intervals, might leak quite a bit! Perhaps as much as 1kB per execution...

Is there anything that I can reasonably do about this? If it means having to go to dynamic arrays and structs, could someone give me a hand on this?

Thanks!

Capt. Picard
02-11-2007, 04:48 AM#2
grim001
Using gamecache is horrible anyway, try downloading Grimoire and using structs and newer things instead
02-11-2007, 09:35 AM#3
Pyrogasm
If you do this:
Collapse JASS:
set string = ""
I believe it makes it take up the least amount of memory possible, though you can't null strings.
02-11-2007, 11:04 AM#4
iNfraNe
thats not true. Strings are just kept in memory so you can reuse them from there, so "nulling" them wont have any effect (ithink)
02-11-2007, 11:39 AM#5
Captain Griffen
You can't stop string leaks.

Another reason to use structs.
02-11-2007, 06:00 PM#6
CaptainPicard
So, in order to use structs, do I have to get Grimoire and JassHelper, or is there some syntax in JASS that allows me to declare my own structs?
02-11-2007, 06:09 PM#7
Captain Griffen
Structs don't actually exist. It's basically an indexed list with parallel arrays.
02-11-2007, 07:41 PM#8
CaptainPicard
Aha. That's what I'm doing, rolling my own, after reading his tutorial. I'll suffer the parallel arrays in my code and probably come out with a bit of a performance advantage.
02-11-2007, 08:02 PM#9
SFilip
There is absolutely no need to worry about string leaks...
First of all the string table gets recycled at some point in-game. This means that it can't really pile up for extremely long games which is good.
Second a string is only added to the table if it doesn't already exist there.
So, a single line set somestring = "abcd" would take the same amount of memory as something like this
Collapse JASS:
loop
    exitwhen i = 1000
    set somestring = "abcd"
    set i = i + 1
endloop
02-11-2007, 08:29 PM#10
Captain Griffen
I have never heard of the string table being recycled, except on loading/reloading.

1,000 handle strings is around 22MB of memory I think.
02-11-2007, 08:43 PM#11
SFilip
It's just a possibility I saw after reading that they change their indexes. I'm probably wrong though.