• 🏆 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!

So.. now I can do GUI... What's a leak?

Status
Not open for further replies.
Level 6
Joined
May 27, 2007
Messages
162
Okay guys, so I've been doing some pretty neat stuff thanks to a helpful tutorial I found regarding Hashtables & MUI.

But, now I want to learn what leaks are, and what custom scripts are available to remove them? :)

Am I right in saying that a 'memory leak' is caused when you use a GUI function that creates a 'local / temporary' variable, and then never really uses it again? So, that it is stored, but not remembered?

So, a 'pick every unit in unit group', will create a temporary variable storing 'picked units', and then that 'variable' must be destroyed?

Same goes for 'create unit at (position of (unit))' etc?

Any help, much appreciated!

Note: Will edit in a second to show off my latest creation :)
 
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Local variables must be nulled and removed.

"Picked unit" is a result of "Unit" variable, so that won't leak. The "Unit Group" from which you pick the "Picked unit" will leak.

Points, Timers, Special Effects, Unit Groups, Player Groups, Sounds, Strings (there is no way of removing them though), Points leak.
Anything object-oriented.
 
Level 6
Joined
May 27, 2007
Messages
162
Thanks Pharaoh_ :)

So, if I'm exploding a Picked Unit. The variable's being destroyed too?

I'm just going to add some finishing touches to my map :), it's nothing fancy - but it's something that the new Diablo III map needs...

Item's (power-ups / health / mana) fly towards the hero, and then are consumed immediately :)

It's like a passive 'knockback' but more like a 'knock-into' :) I'm quite proud of it. Now, to make it leak-less!
 
You spoke of GUI. Locals involve Jass, so, in GUI, they involve Custom script to create them. You need to initially realize the difference of Globals vs. Locals. Globals are the ones GUI can generate (this issue has been lifted in Galaxy Editor - GUI can generate locals). The prefix of globals is "udg_".

So, if you explode "Picked unit" like this:
  • Set Unit1 = (Picked unit)
  • Unit - Explode Unit1
The global variable will return null when the unit is exploded (since explode automatically removes the unit from game almost instantly (it actually involves the actions of Unit - Kill Unit and Unit - Remove Unit at the same time)), and, when you are going to use that ability again, the new (Picked unit) will become the new "Unit1".
If you use locals though,
  • Custom script: local unit u = GetTriggerUnit()
  • Custom script: set u = null
It would require you to null the unit afterwards, when you don't have to do that, if you are using global variables.

Most indexing systems require you to null your units though:
  • Custom script: set udg_Caster[udg_Loop2] = null
 
Level 6
Joined
May 27, 2007
Messages
162
A Global variable is something that every function in a program recognizes, in other programming languages, Global Variables are declared at the top - ie. declare ThisVariable as Integer, or declare ThatVariable as String.

My question now, would be, GUI is obviously limited in that it only uses Globals. Is a Local - in Jass - recognized only by the one trigger it is created in? Or can you pass locals between triggers?

A part of me is sad that the Galaxy Editor has such an improved GUI - but, the other part , since the Galaxy Editor uses C# / Java for scripting, makes me glad. I just can't wait to get a beta-key or until the 27th of July!

Pharaoh_ you will still be answering all my questions on the SC2 modding threads, yes? :

I am going to post a couple triggers on here in a while, and try and point out where I think things are leaking. Then using the custom scripts BJ_WantDestroyGroup = true and RemoveLocation(udg_loc) etc... Should be fun! :)
 
Status
Not open for further replies.
Top