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?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>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.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
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.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>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 : )
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
its safe, no leaks when you clear the childtables.

hashtables can even be used with GUI without memory leaks.
 

Jedi

New Member
Reaction score
63
Umm, flush parents?
It doesn't matter they exist unless you save something and forgot to flush.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
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
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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