• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Things that Leak within another variable

Status
Not open for further replies.
Level 7
Joined
Jun 19, 2017
Messages
141
I was wondering if things that leak, are also leaking if they are used within another variable, like in this case. Does the point within the unit group variable leak ?
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    20 KB · Views: 95

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
If there would be a point, it would leak. In this case it is only a constant region, so it does not leak. If you would create the region dynamically and don't remove it, it would leak though.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
point = location
region = rect

A leak doesn't occure just because you use a variable of a certain type like a point or unit group.
A leak occurs if:
1.you create an object
2.you don't remove the object
3.you lose reference to the object, so you can no longer remove it

playable map area is created at the beginning of the map and you never lose reference to it, so it does not leak.
If you would create a region dynamically for example with convert coordinates to region like here:
  • Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across (Region(-50.00, -50.00, 50.00, 50.00))
it would leak, so you would need to store the region in a variable and use a custom script to remove that region

A dynamically created object is created at some point in the game, in most cases they should be removed at some point as well.
objects can also be created at map initialization. In that case they are only created once and are often needed for the rest of the game, so they don't need to be removed.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
I was wondering if things that leak, are also leaking if they are used within another variable, like in this case. Does the point within the unit group variable leak ?
What you are asking makes no sense. Please look at the underlying JASS code GUI compiles into, things make a lot more sense then.

WC3 mostly lacks automatic garbage collection. Every object you allocate must be destroyed.
 
Status
Not open for further replies.
Top