Hashtables and Memory Leaks

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
1. I set TempPoint to be Position of (Triggering Unit).
2. I save TempPoint as Key(Triggering Unit) of LocationInteger in Hashtable.
3. I do call RemoveLocation(udg_TempPoint).
4. In a separate trigger, I Create 1 Footman for (Owner of (Triggering unit)) at (Load (Key (Triggering unit)) of LocationInteger in Hashtable) facing Default building facing degrees.
5. Nothing appears.

Is there any other way to do this? And I'm not too sure when to use Clear Parent Hashtable and Clear Child Hashtable - do they clear leaks as well?
 

Curo

Why am I still playing this game...?
Reaction score
109
You have it backwards. You are supposed to load LocationInteger of (Key (Triggering unit)). Clearing just removes all the current values.
 

HydraRancher

Truth begins in lies
Reaction score
197
You want to clear things when you're done with them.


Imagine it like an Array.

When you set TempPoint as Key(LocationInteger), you're basically saving it as a value (like 2) in an array, (Key(Triggering Unit)).

Triggering Unit being your array, and LocationInteger being the index.
 

Curo

Why am I still playing this game...?
Reaction score
109
Actually, now that I think of it, his way may still work (although you definitely want to switch it).

I think he's having a similar problem to me:

Trigger:
  • Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Hashtable - Save 400.00 as (Key distance) of (Key (Target unit of ability being cast)) in movement_table
      • Game - Display to (All players) for 5.00 seconds the text: (Distance = + (String((Load (Key distance) of (Key (Target unit of ability being cast)) from movement_table))))


The string displays "Distance = 0.000", for me. Why isn't it 400.000?
 

HydraRancher

Truth begins in lies
Reaction score
197
Have you created the hashtable? :3

Btw, when I save values, I save it like, Save 400.00 as 0 of (Key (Whatever)) in TABLE.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
So, if you save A as B of C in Hashtable, then you should load C of B in Hashtable to get A?
 

HydraRancher

Truth begins in lies
Reaction score
197
No.

It's basically a 2D array.

A is your Data.

B is your Index.

C is your Array/Key.

If you save A as B in C.

To load A back, you load B from C.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
So does using Hashtable - Clear actions do the same thing as leak-clearing functions like call RemoveLocation?
 

Bankde

Member
Reaction score
20
I believe "Location Hashtable" is bug and cannot be used.
Use GetLocationX and GetLocationY (It's jass) which will return real then save real in hashtable. In other trigger, use Location(Load...., Load.....)
Real is not leak and will make trigger run faster.
 

HydraRancher

Truth begins in lies
Reaction score
197
Location Hashtable isn't bugged. I've used it before.


Does your current trigger work? If not, show it.
 

KJP

New Member
Reaction score
5
1. I set TempPoint to be Position of (Triggering Unit).
2. I save TempPoint as Key(Triggering Unit) of LocationInteger in Hashtable.
3. I do call RemoveLocation(udg_TempPoint).
4. In a separate trigger, I Create 1 Footman for (Owner of (Triggering unit)) at (Load (Key (Triggering unit)) of LocationInteger in Hashtable) facing Default building facing degrees.
5. Nothing appears.

Is there any other way to do this? And I'm not too sure when to use Clear Parent Hashtable and Clear Child Hashtable - do they clear leaks as well?
.

Just something that seems a little obvious to me, but how exactly does the seperate trigger in point 4 fire. I think if its not called directly by the first trigger then there will no triggering unit.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Whoops, forgot to mention that. The other trigger is a periodic that runs every 0.03 seconds. (Triggering Unit) in that point refers to the original unit. I saved it into Hashtable, and the loading of the unit works fine. It's the loading of the point that's the problem - does clearing TempPoint empty the value saved in Hashtable?
 

Romek

Super Moderator
Reaction score
963
You should only remove the leak once you're finished with the location handle. Take a guess as to what [ljass]RemoveLocation[/ljass] does. Now ask yourself why you can't use that location afterwards.
 

HydraRancher

Truth begins in lies
Reaction score
197
When ever I've saved points into hashtables I save them directly. Like saving (Position of (Triggering Unit)). But does that create leaks?
 

HydraRancher

Truth begins in lies
Reaction score
197
I would presume not. Because you aren't using the point, merely storing it for access. It's the same thing as setting TempPoint[1] as Center of (Playable Map Area) isn't it? Using an array.
 

Curo

Why am I still playing this game...?
Reaction score
109
Have you created the hashtable? :3

Btw, when I save values, I save it like, Save 400.00 as 0 of (Key (Whatever)) in TABLE.

I think...I forgot to create the hashtable! Lol so simple and I've been slaving over this problem for days. Thank you, my man. I can't stop laughing at my stupidity.

0 works, but I like to use strings so I can remember what 0 represents. Especially when dealing with multiple values at once.

You should only remove the leak once you're finished with the location handle. Take a guess as to what [ljass]RemoveLocation[/ljass] does. Now ask yourself why you can't use that location afterwards.

So if I set TempPoint = (Position of (Triggering unit)), save TempPoint as 0 of whatever in hashtable, then RemoveLocation to clean up the leak...I won't be able to pull that point up through the hashtable anymore? Good to know, if I'm interpreting you correctly.
 

HydraRancher

Truth begins in lies
Reaction score
197
So if I set TempPoint = (Position of (Triggering unit)), save TempPoint as 0 of whatever in hashtable, then RemoveLocation to clean up the leak...I won't be able to pull that point up through the hashtable anymore? Good to know, if I'm interpreting you correctly.

I believe that's what Romek means.
 

Bankde

Member
Reaction score
20
Location Hashtable isn't bugged. I've used it before.
Does your current trigger work? If not, show it.

Definitely NOT (It ruins my trigger as well, seems that location isn't exist). Anyway I have changed save location to save real(LocX and LocY) instead and it works efficiently. (I don't really care much about leak but this force me to use real :p)

You should only remove the leak once you're finished with the location handle. Take a guess as to what RemoveLocation does. Now ask yourself why you can't use that location afterwards.

This may explain the reason why.

Believe me, use GetLocationX and GetLocationY is better.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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