• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Question about memoryleaks using Timer and SaveHandles

Status
Not open for further replies.
Level 3
Joined
Aug 27, 2011
Messages
41
I was wondering when using a function like
Code:
SaveUnitHandle(hash, GetHandleId(timer), 0, unit)

when you load using
Code:
unit = LoadUnitHandle(hash, GetHandleId(timer), 0)

when you null the unit out at the end does it also null the hash's field as well? Does it still contain the variable place holder, or since it saves the handle which is a integer does it not need to be nulled?
 
It doesn't null the hash field. To remove the data from the hash field, you must use:
JASS:
call RemoveSavedHandle(hash, GetHandleId(timer), 0)
Or you can flush the entire parent key:
JASS:
call  FlushChildHashtable(hash, GetHandleId(timer))

The first will just clear the data for that specific handle saved in that area. The second will clear all data saved under the handle id of timer.
 
Level 3
Joined
Aug 27, 2011
Messages
41
Oh dang, I was afraid of that, lol. Most of my coding is done in C++ and C#. So I'm used to values just being values, whether the value is a object or not lol. But I was looking at the code earlier and started thinking about having to null the hash field as well.

Thanks for letting me know I don't know how big of a memory leak it would of been but I'm glad I know now XD.
 
How difficult are they to learn and how efficient are they compared to hashes?

It is not difficult to learn, but it may be harder if you do not know vJASS. However, Table essentially is just a nicer API (programming interface), it doesn't improve the speed or anything like that. (since it uses hashtables itself, hence the name Table) You can stick with normal hashtables if you are already comfortable with them. :)
 
Status
Not open for further replies.
Top