hashtable memory usage

W!†A_cRaft

Ultra Cool Member
Reaction score
28
If i was to for example create a hashtable with parameters like this:

JASS:
local integer i = 0
local integer j = 0
local unit u = <some unit>
loop
     exitwhen i == 100
     loop
          exitwhen j == 20
          SaveUnit (udg_hash, i,j,u)
          set j = j + 1
     endloop
     set i = i + 1
endloop

Now if i for example want to clear a certain part of the table lets say

JASS:

local integer i = 10
loop
     exitwhen i == 15
     call FlushChildHashtabled(i)
     set i = i + 1
endloop

Code:
now if i take a look at my hashtable it will have fields like:
        1    2    3   4   5   6   7   8   9   10    11   12   13  14  15  16  17  .  .   .20
1      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
2      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
3      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
4      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
5      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
6      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
7      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
8      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
9      u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
10     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   .
11     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   .
12     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   . 
13     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   .
14     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   .
15     .     .    .   .   .   .   .   .   .    .     .    .   .    .   .    .   .
16     u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u 
17     u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u
.
.
100    u     u    u   u   u   u   u   u   u    u     u    u   u    u   u   u    u

These 5 empty fields that i gotten by flushing child hashtable are still there, they are just empty?

Now if i lets say add another "row" basically 101, will it overwrite a place in memory that was empty or will it just make a new row.

if it makes a new row, do these empty rows cause lag/delay and things like that?
 
>if it makes a new row, do these empty rows cause lag/delay and things like that?

Of course not : ). This is Blizzard's implementation of a hash table specially designed for their awards winning game and by top level programmers.

I think I read somewhere that they had to pull some extra crew from d2/3 team to help fix the return bug exploits. But they had to replace the lost functionality for the popular maps (like TcX, and I think some map called dota? ... idr) so they added those new natives. It's a win win except for the thousands of old and good maps that got broken.


about:
>These 5 empty fields that i gotten by flushing child hashtable are still there, they are just empty?
and
>Now if i lets say add another "row" basically 101, will it overwrite a place in memory that was empty or will it just make a new row.

Well I don't really know much(null actually ; )) details about the internal implementation of a hash table but I guess it's made that it is pretty efficient.
 
well the only thing that has me worried is the "overtime lag/gameslowment" because RAM memory would get used up with parent keys.

I am using something like this:

a 2 unit relation, stored in a hashtable:
Unit A - Get unit Id 1
Unit B - Get unit Id 2
SaveData(hash, ID1, ID2, value)

and when unit A decays (i.e. loses his ID) i use a FlushChildHash(ID1) to clear all the data related to that unit...all the data except the parent key which is still in the hashtable....

so if for example every unit in my map decays i would have one BIG empty hash table filled with parent keys.... Would this still take up place in RAM memory?

I mean there would be a TON of relations in my map, but only like 20-40 relations at every single time, after which, they are dumped, that is why i need to know if it will cause RAM clogging.
 
>that is why i need to know if it will cause RAM clogging.

I like to think about a blizzard's hashtable like a black hole that can take any amount of punishment(inserting/saving) and (unlike a black hole) return it without any overhead.

If you really want to "save" the ram then I guess you could use the gamecache which saves it's data to the hard drive so it's more or less infinite and clogging-proof : )
 
its safe, no leaks when you clear the childtables.

hashtables can even be used with GUI without memory leaks.
 
Umm, flush parents?
It doesn't matter they exist unless you save something and forgot to flush.
 
JASS:

// Those clear individual entries
native  RemoveSavedInteger                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedReal                        takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedBoolean                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedString                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedHandle                    takes hashtable table, integer parentKey, integer childKey returns nothing

// Clears the whole hashtable
native  FlushParentHashtable                        takes hashtable table returns nothing
// Clears an individual parentKey
native  FlushChildHashtable                    takes hashtable table, integer parentKey returns nothing
 
JASS:
// Those clear individual entries
native  RemoveSavedInteger                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedReal                        takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedBoolean                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedString                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedHandle


wouldn't these still leave parent keys in the hashtable?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top