| 01-19-2010, 04:54 AM | #1 |
The first I heard of it was this post by Fledermaus, then I went to confirm it myself: JASS:library Bla initializer Init globals private integer N = 0 endglobals private function Test takes nothing returns nothing local hashtable ht = InitHashtable() call SaveInteger(ht, 0, 0, 1) if LoadInteger(ht, 0, 0) == 1 then set N = N + 1 call ClearTextMessages() call BJDebugMsg("Worked with "+I2S(N)+" hashtables") else call BJDebugMsg("Failed after "+I2S(N)+" hashtables") call PauseTimer(GetExpiredTimer()) endif endfunction private function Init takes nothing returns nothing call TimerStart(CreateTimer(), 0.01, true, function Test) endfunction endlibrary This code prints "Failed after 255 hashtables," in other words, the 256th hashtable fails to work at all. Curse Blizzard's lameness. This limit isn't too bad unless you have many libraries in your map that each declare their own hashtables. But now we know that any system that can consolidate its hashtable usage using Table should do so, not just for aesthetic reasons. |
| 01-19-2010, 05:17 AM | #2 |
same limit with gamecache but everything worked fine for 8 years... |
| 01-19-2010, 05:33 AM | #3 | |
Quote:
Gamecache didn't exactly work fine. In single player, gamecaches could pile up and eventually stop working. We used Table to consolidate gamecache usage to deal with that. Also, people were thinking of using hashtables in ways GC was never used, but that's not so viable with a 255 instance limit... |
| 01-19-2010, 06:23 AM | #4 |
there is no way to fill 2^32 keyspace, multiple hashtabled is waste of memory. |
| 01-19-2010, 06:27 AM | #5 |
@grim001 why did you worry about that? every hashtable has 2 unlimited keys --> you could store an unlimited number of things. And then it's equal how many hastables you can create @DioD fully agree |
| 01-19-2010, 06:29 AM | #6 |
That's like saying you don't need more than 255 arrays because you wouldn't need more than 2088450 values. The point is that you need to map a specific integer/integer combination to another value. This either requires a new hashtable in each chase, or Table usage. I find it doubtful that any map would actually hit this 255 limit just by importing enough libraries that declare their own. I am not really worried about it, but it's just something people should be aware of. |
| 01-19-2010, 06:39 AM | #7 |
no, arrays are limited, hashtables unlimited !!666th post!! |
| 01-19-2010, 06:51 AM | #8 |
18446744073709551616 possible keys per single hashtable 4703919738795935662080 for 255 hashtables this is over 4gb (memory size limit for 32bit OS) |
| 01-19-2010, 08:08 AM | #9 |
For example you can't really use an hashtable as an unlimited 2D array, else you would quickly reach the limit of 255. Well ofc it still can be done, but not in a native way. It's still good to know. Also i suppose a big hashtable with a lot of datas is much slower than several small ones ? |
| 01-19-2010, 08:27 AM | #10 |
I wonder why didn't they add a changeable integer that gives you the maximum amount of indexes for the hashtable you are creating? local hashtable hash = InitHashtable(255)... |
| 01-19-2010, 08:37 AM | #11 |
And that would be usefull for ? You could still use a hook and increment a global variable, when InitHashtable is called anyway. But i suppose you won't be able to use this native in a global declaration, i only use initializers personally, because some natives inside a global declaration can crash the map. |
| 01-19-2010, 08:41 AM | #12 | |
Quote:
I guess there is always a way to hack, but really, a limit should be settable. |
| 01-19-2010, 08:44 AM | #13 |
I still don't see the concrete usefulness of a such thing. We know the limit now, just don't reach it. |
| 01-19-2010, 08:52 AM | #14 |
255 hashtables can be reached easily, by having a hashtable for every player in a few systems. 15 * 12 = 180. Also, a limit would allow to get more or less hashtables, depending on what you need. This will make things easier to not reach the limit at all. JASS:local hashtable hash = InitLimitedHashtable(255) |
| 01-19-2010, 09:14 AM | #15 | ||
Quote:
Quote:
But this would be useful information... go someone bench it ! |
