HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Memory Leak Fixes?

01-18-2007, 03:42 PM#1
Ghost.X
Can ya'll tell me all the custom script commands I can add to my GUI to get rid of memory leaks? Such as unit groups, points (especially points), the whole shabange. I would really appreciate it.
01-18-2007, 04:50 PM#2
BertTheJasser
Collapse JASS:
call RemoveLocation(udg_yourLocation)
//udg_ user defined globals, prefix used by globals you define

Collapse JASS:
call DestroyGroup(udg_yourGroup)

The biggest problem is, that will opnly solve hhalf of the leaks. The other half is caused by BJ functions hostaging handle indices, which GUI, and only GUI, uses.

Btw. can anybody explain me how to use [|jass] =?
01-18-2007, 04:52 PM#3
The)TideHunter(
Ok.
Use any of these commands in a Custom Script GUI line, with the variable inside the command, and global variables need a udg_ before them.

Remove commands:
Collapse JASS:
native RemoveDestructable          takes destructable d returns nothing
native RemoveItem      takes item whichItem returns nothing // Item
native RemoveLocation           takes location whichLocation returns nothing // Point
native RemoveRect               takes rect whichRect returns nothing // TriggerCreated Region's
native RemoveRegion             takes region whichRegion returns nothing // UserCreated Regions
native RemoveUnit          takes unit whichUnit returns nothing // Unit
native RemoveWeatherEffect          takes weathereffect whichEffect returns nothing // Weather Effect

And Destroy:

Collapse JASS:
native DestroyBoolExpr  takes boolexpr e returns nothing // Jass Only
native DestroyEffect                takes effect whichEffect returns nothing // Special Effect
native DestroyForce             takes force whichForce returns nothing // Player Group
native DestroyGroup                         takes group whichGroup returns nothing // Unit Group
native DestroyImage                 takes image whichImage returns nothing // Image
native DestroyLeaderboard               takes leaderboard lb returns nothing // Leaderboard
native DestroyLightning             takes lightning whichBolt returns boolean // Lightning
native DestroyMultiboard                takes multiboard lb returns nothing // Multiboard
native DestroyQuest         takes quest whichQuest returns nothing // Quest
native DestroyTextTag               takes texttag t returns nothing // Floating Text
native DestroyTimer         takes timer whichTimer returns nothing // Timer
native DestroyTimerDialog               takes timerdialog whichDialog returns nothing // Timer Dialog
native DestroyTrigger   takes trigger whichTrigger returns nothing // Trigger
native DestroyUbersplat             takes ubersplat whichSplat returns nothing // Ubersplat

Some of those functions are unneccersary if you are trying to aviod leaks they can all come in handy from time to time.

Example:

Trigger:
Actions:
set MyPoint = Position of MyUnit
Custom Script: call RemoveLocation(udg_MyPoint)

The thing to remember is, when you use functions like Position of SomeUnit, it creates a position, which takes memory, and you cant find it once you use it, unless you save the position to a variable, use it then destroy it, it solves all the problems.

Main leakage functions:

Position of SomeUnit
Get all units in ~Criteria~

Final Example:

Example of creating a unit at a spell target location, which leaks:
Trigger:
Actions
Unit - Create 1 Peasant for Player 1 (Red) at (Target point of ability being cast) facing Default building facing degrees

Example of creating a unit at a spell target location, which dosent leak:
Trigger:
Actions
Set TempLocation = (Target point of ability being cast)
Unit - Create 1 Peasant for Player 1 (Red) at TempLocation facing Default building facing degrees
Custom script: call RemoveLocation(udg_TempLocation)
01-18-2007, 09:34 PM#4
Ghost.X
Ok thanks, those will come in handy. Especially considering that one of my GUI spells named the "Chaingun" uses like 75 points in one trigger. Wanna know why XD!