HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

So, InitGameCache Leaks...

11-18-2004, 12:00 PM#1
Vexorian
http://www.wc3campaigns.com/showthread.php?t=67894

After a 3 days rest from wc3, I got to test that map, and yes InitGameCache leaks, I am not very surprised because blizzard seems to do this kind of weird stuff everytime, It seems InitGameCache besides of 'initializing' the hash table, also creates a pointer like the locations to it.

I was trying to fix the leak and I found that SaveGameCache actually cleans the pointer , it would work heavenly in multiplayer, but in singleplayer, it would save everything from the gamecache causing a big slowness.

FlushGameCache also cleans the pointer, but it also wipes the hash table.

So the only way, unfortunally, to fix this leak is to use a global gamecache variable, but keep in mind you must make sure of initializing it before it is used anywhere, or a dummy function

Code:
function CSCache takes nothing returns gamecache
    if udg_cscache==null then
         set udg_cscache=InitGameCache("castersystem.vx")
    endif
 return udg_cscache
endfunction

Makes you wonder why you aren't able to initialize gamecaches in the variables declarat ion dialog.

Anyways, tons of systems are leaking at this moment, probably weaddar's bag , and specially all the stuff made by me, like the events and the templates system, and also 2 or 3 versions of the handle variables functions, at least with my stuff, you can replace them with a function like the one I am showing. People like AIAndy and Darky were right to force the use of a variable (Even while Darky used a typecasted trigger variable)

This will probably fix the concept gamecache was slow, because with this fix you can experience a huge speed boost.
11-18-2004, 02:14 PM#2
Ryude
I'm not surprised either, why should blizzard put forth any more effort into world editor. It's not like it's going to bring them any more profit. Plus, they have other titles they need to tend to, but at least we have people working with the world editor that can show us how to fix these problems =P Thx
11-18-2004, 03:12 PM#3
KaTTaNa
This is exactly what I discovered yesterday as well:
http://www.wc3sear.ch/viewtopic.php?p=44005#44005

It really annoys me because back when the gamecache was starting to get regularly used, I thought InitGameCache would leak but people selfconfidently told me that it didn't.

I also came to the conclusion that a global is the way to do it.
11-18-2004, 05:53 PM#4
Luzif3r
because im not much into in the materia, could you please tell me which systems/functions will gain a "huge speed boost"? i myself never noticed a noticable lag with gamecache. soooo...
11-19-2004, 10:00 AM#5
KaTTaNa
It means that whenever you used one of the handle var functions (found here) you leave behind some garbage in the memory.
That garbage will continue to pile up and after an hour of gameplay it can turn the game into a lagfest - depending on how often you use it of course.

The solution - as mentioned - is to use a global variable containing the gamecache instead of using InitGameCache all the time.
11-19-2004, 03:53 PM#6
curi
hey just an idea, i don't really know how to do this, but: would it be worthwhile to try to convince Blizzard to include a declaration of a global gamecache var in blizzard.j for us to use?

Another idea (bad) is to use bj_lastCreatedGameCache and pretend it's ours. This would work as long as people created gamecaches with the common.j function, but would mess up when someone who didn't understand tried to use some jass functions and also created gamecaches w/ the GUI in the same map.
11-19-2004, 07:55 PM#7
PitzerMike
I think we should agree on some unused bj globals that will be reserved for use as game cache variables.
I myself have always been using boolean array bj_slotControlUsed (which is only used from index 0 to 15 /16) so any index above 16 will work just fine.

Basically one single global could also do the job, as long as we use the same file name but keep the key/subkey combinations unique for each of our systems.
11-20-2004, 11:56 AM#8
Vexorian
It is more of a problem to type cast stuff than to make people paste variables.

Quote:
This is exactly what I discovered yesterday as well:
http://www.wc3sear.ch/viewtopic.php?p=44005#44005

It really annoys me because back when the gamecache was starting to get regularly used, I thought InitGameCache would leak but people selfconfidently told me that it didn't.

I also came to the conclusion that a global is the way to do it

Oh, please don't use wc3search's forums, nobody uses them, anyways, I don't remember the moment you said it would leak, I only remember other people saying it would be better to use globals, but they didn't backuped, If I would read anywhere that it might leak, I would have tested it, like when somebody said Exploding or Life timers leaked the units, I found they don't at all.

And the other day someguy at bnet was saying that the GroupEnum functions leaked, btw, but after testing I found they don't actually leak, the native seems to destroy its created auxiliar data a while after it is used (this is because the memory counted rised indeed, but it got to a moment the memory usage was constant)
11-20-2004, 08:44 PM#9
Guest
Now things are to be remade, good luck, luckily I haven't touched any suspectious code out there... :8
11-21-2004, 09:39 PM#10
Vexorian
Now , I am getting sick of you, why do you think the code is suspicious? it is not my fault you fear JASS that much.
11-22-2004, 05:28 AM#11
Guest
I am not talking about your code, but anything that is 3rdparty code for public use.

I use WEU but never set up advanced triggers. If I need one, I go through the additional functions in the database and CnP the one I need after I find it's OK.

Same for every other. (yet, except codes from uber programming languages which I have no way to suspect)

Take comments easy, Lord Vexorian, I never meant to blame others' work, it is just my way, I often don't believe in things unchecked. (oh well, still I am using your well done Optimizer though there is gonna be some bugs ^_^ )