Game.DoOnceOnly() - any drawbacks?

Started by Jared, Fri 09/04/2010 06:40:33

Previous topic - Next topic

Jared

Could just be my paranoid mind at work but I'm wondering if there are any negative features or just plain reasons to show restraint when using Game.DoOnceOnly(). It's an incredibly useful function and I think I've put at the very least a dozen of them in my game so far.

I'm guessing from the way it's set out that it creates a set of booleans at run-time named from the value in the method, and these booleans become more Global Ints that get stored in the memory in run-time - I can't remember exactly but ISTR booleans equal around 1 byte of memory each as one of the most primitive types. I thought I'd check if maybe it was a little more complicated than that.

I've gotten into the habit of using this code so often that I felt a need to check if it had any sort of limitation at all other than memory use. Just to be on the safe side.

Khris

My guess is that a hash value is generated from the string which is then searched for in a dynamic int array. If it's already in there, the function returns false, otherwise the value is stored in the array and true is returned.

Assuming 32bit hash values, 50 of them, the approximate amount of memory is around 0,00000931% of the average total available memory.

In short: There probably is no memory hog. Now stop worrying and enjoy your life. ;)

Jared


SMF spam blocked by CleanTalk