What are handles?

Legacyspy

New Member
Reaction score
19
I've seen this referenced a lot and I don't understand what they are other than some sort of stored info.
Also I recall hearing about a handle counter that would display it in game, could anyone link to one?
 

Romek

Super Moderator
Reaction score
964
A handle is everything that isn't an integer, real, string, boolean or code.
Basically objects in the game, such as units, triggers, timers, etc.

Most local handles need to be nulled, as they leak.

Handle counters basically show you if your map is leaking handles or not.
If the count goes up constantly; chances are that your map leaks.
It'll go up when units are created, etc.

This is my Handle Counter. It shows the count, and how much it's increase/decreased in the past second.
JASS:
library HandleCounter initializer Init 
//  ________________________________________
// +----------------------------------------+
// |    H A N D L E   C O U N T E R   v1    |
// +----------------------------------------+
// |      By Romek - For his Demo Map       |
// |________________________________________|
// +----------------------------------------+

// Frankly, I don't care about the efficiency of a handle counter.
// Nor do I care about how well a temporary script is coded. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    globals
        private leaderboard LB
        private location array Loc
        
        private constant integer DEC = 0x100000
        
        private integer Last = DEC * DEC
        private integer Curr = 0
        private integer Change = 0
    endglobals
    
    private struct T extends array
        static integer S = 0
        static integer M = 0
        static integer H = 0
        
        static string SS = &quot;00&quot;
        static string MS = &quot;00&quot;
        static string HS = &quot;00&quot;
    endstruct
    
    private function H2I takes handle h returns integer
        return h
        return 0
    endfunction
    
    private function Expire takes nothing returns nothing
        local integer i = 0
    
        set T.S = T.S + 1
        if T.S &gt; 60 then
            set T.S = 1
            set T.M = T.M + 1
            
            if T.M &gt;= 10 then
                set T.MS = I2S(T.M)
            else
                set T.MS = &quot;0&quot; + I2S(T.M)
            endif
        endif
        if T.M &gt; 60 then
            set T.M = 1
            set T.H = T.H + 1
            
            if T.H &gt;= 10 then
                set T.HS = I2S(T.H)
            else
                set T.HS = &quot;0&quot; + I2S(T.H)
            endif
        endif
        
        if T.S &gt;= 10 then
            set T.SS = I2S(T.S)
        else
            set T.SS = &quot;0&quot; + I2S(T.S)
        endif
        
        call LeaderboardSetItemLabel(LB, 2, &quot;                 &quot; + T.HS + &quot;:&quot; + T.MS + &quot;:&quot; + T.SS)
        
        loop
            set i = i + 1
            set Loc<i> = Location(0., 0.)
            exitwhen i == 100
        endloop
        set Curr = (H2I(Loc[100]) - DEC) - 100
        call LeaderboardSetItemValue(LB, 0, Curr)
        loop
            call RemoveLocation(Loc<i>)
            set Loc<i> = null
            set i = i - 1
            exitwhen i &lt; 0
        endloop
        
        set Change = Curr - Last
        set Last = Curr
        if Change &gt; 0 then
            call LeaderboardSetItemValue(LB, 1, Change)
            call LeaderboardSetItemValueColor(LB, 1, 0xFF, 0, 0, 0xFF)
        else
            call LeaderboardSetItemValue(LB, 1, Change)
            call LeaderboardSetItemValueColor(LB, 1, 0, 0xFF, 0, 0xFF)
        endif
    endfunction

    private function Start takes nothing returns nothing
        set LB = CreateLeaderboard()
        
        //call LeaderboardSetLabel(LB, &quot;       Handle Counter:&quot;)
        call LeaderboardSetLabel(LB, &quot;&quot;)
        call PlayerSetLeaderboard(GetLocalPlayer(), LB)
        call LeaderboardAddItem(LB, &quot;Handles:&quot;, 0, Player(15))
        call LeaderboardAddItem(LB, &quot;Change:&quot;, 0, Player(15))
        call LeaderboardAddItem(LB, &quot;                 00:00:00&quot;, 0, Player(15))
        
        // Colours of the LABELS
        call LeaderboardSetItemLabelColor(LB, 0, 0xFF, 0xDF, 0x00, 0xFF) // Handles
        call LeaderboardSetItemLabelColor(LB, 1, 0x00, 0xB7, 0xEB, 0xFF) // Changed
        call LeaderboardSetItemLabelColor(LB, 2, 0x77, 0x77, 0x77, 0xFF) // Time
        
        // Colours of the ITEMS. (Except &#039;Changed:&#039;)
        call LeaderboardSetItemValueColor(LB, 0, 0xFF, 0xFF, 0xFF, 0xFF)
        call LeaderboardSetItemValueColor(LB, 2, 13, 33, 37, 0) // Making the Time one invisible

        
        call LeaderboardSetSizeByItemCount(LB, 2)
        call LeaderboardDisplay(LB, true)
        
        call TimerStart(GetExpiredTimer(), 1., true, function Expire)
    endfunction

    private function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0., false, function Start)
    endfunction
    
endlibrary</i></i></i>
 

Romek

Super Moderator
Reaction score
964
It shows how many handles you have in-game.
It can assist with showing you if you have handle leaks, yes.
It doesn't tell you what leaks, or where.

It's worth noting that the count will increase when non-leaking handles are created. So if you create a unit, for example, the count will go up.
If the count increases periodically and nothing visible is being created, then chances are, your map leaks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top