• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[General] Something about memory leaks

Status
Not open for further replies.
Level 9
Joined
Dec 31, 2016
Messages
320
Well, I have this trigger. Do i need to always use "call RemoveLocation...", after "Point" variable, to remove leaks or it will overwrite itself every time it is used, so no memory leaks will occur?
  • Reinforcements
    • Events
      • Time - Reinforcements expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set Point = (Random point in Reinforcements <gen>)
          • Unit - Create 1 Archer for Player 2 (Blue) at Point facing Default building facing degrees
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer A) Less than or equal to 2
            • Then - Actions
              • Set Point = (Random point in Reinforcements <gen>)
              • Unit - Create 1 Huntress for Player 2 (Blue) at Point facing Default building facing degrees
            • Else - Actions
      • Set Group = (Units in Reinforcements <gen>)
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set Point = (Random point in Reinforcements Dest <gen>)
          • Unit - Order (Picked unit) to Attack-Move To Point
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
All JASS variables are 32 bits. How complex objects like locations work is by allocating the object separately on the heap and then storing a reference to that object in the variable. The references come in the forms of handles, which are indices into a handle table which then contains the address of the actual object.

For all resources to be freed, the object must be destroyed by appropriate destructor and all variables referencing it must be assigned other values to allow the handle index to be recycled.
 
Every time, I think.

the value of the variable goes in the same place in memory, but the instsance point it is pulling the value from is unique and needs to be destroyed in an ideal memory management scenario.

All JASS variables are 32 bits. How complex objects like locations work is by allocating the object separately on the heap and then storing a reference to that object in the variable. The references come in the forms of handles, which are indices into a handle table which then contains the address of the actual object.

For all resources to be freed, the object must be destroyed by appropriate destructor and all variables referencing it must be assigned other values to allow the handle index to be recycled.

I like the three different ways this was explained
 
Status
Not open for further replies.
Top