(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Modding > World Editor Help Zone

World Editor Help Zone Need help with Blizzard's World Editor? Ask general questions about its features and use in this forum. README!

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 09-04-2005, 07:04 PM   #1 (permalink)

User
 
Join Date: Sep 2005
Posts: 3

glock is an unknown quantity at this point (0)


memory leaks

does anybody here know how to stop some or all memory leaks? my map lags bad and i want it to stop

help me :!:
glock is offline  
Old 09-18-2005, 06:00 PM   #2 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)


what makes it lag?
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 09-21-2005, 04:22 AM   #3 (permalink)
 
teza89's Avatar

User
 
Join Date: Sep 2005
Posts: 234

teza89 is an unknown quantity at this point (0)


Re: memory leaks

spawning creeps and mass dialogs can make it lag
teza89 is offline  
Old 09-21-2005, 09:23 PM   #4 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)


in many td's it laggs a lot when creeps spawns. Also just MANY creeps makes lagg.
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 09-23-2005, 01:18 AM   #5 (permalink)
 
teza89's Avatar

User
 
Join Date: Sep 2005
Posts: 234

teza89 is an unknown quantity at this point (0)


Re: memory leaks

yea but what are memory leaks?
teza89 is offline  
Old 09-24-2005, 12:45 AM   #6 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)


dunno :S
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 09-26-2005, 09:37 PM   #7 (permalink)
 
Thunder_eye's Avatar

User
 
Join Date: May 2004
Posts: 207

Thunder_eye has little to show at this moment (5)


Re: memory leaks

Lets start with a brief overwiev of how leaks happen, or more precisely, how handle object leaks happen. These memory leaks are what we deal with the most, there are others, like string leaks (which can't be prevented at all, but are usually insignificant), and the problem with local handle variables (which is a part of handle object leaks but won't be covered here for the sake of keeping it short and simple, because local variables are only used in JASS anyway). By the way, custom scripts are JASS.

Handles are game objects... units, doodads, destructibles, items, special effects and also regions, locations, unit groups, player groups... all this stuff. Things that are not handles are integers, reals, booleans; these are just numbers. They are stored in their variables and are erased the moment the variable is set to a new value.

Handle variables, on the other hand, are pointers: they only contain a number that points to where in the game's memory the object is located. Handle objects exist independant of variables. They can exist without any variables pointing to them, in that case, they can't be removed from memory because there's no way to tell the functions that are used to remove them where in the memory they are. Such unreferenced handles are only cleared from memory at the end of a game by a garbage collector (the source of end game delay), but while the game lasts, they accumulate and can cause performance issues.

Now, there are plenty of functions that create handles. Center of region, random point in region, position of unit, target point of ability being cast... and many others create a location object, which is usually used to create units at, or special effects, or for measuring distances between points... Units in region, units owned by player, units in range,... all these functions give you a Unit Group. Then there are player groups and all other things already mentioned and more.

You may only need these objects for a moment, but the game can't know that, so they don't just go away by themselves when you no longer need them. The location doesn't just dissapear once a unit is created at it. We must use special functions to dispose of the handles we only create temporarily and don't need them to last. The most commonly used are:
RemoveLocation()
DestroyGroup()
DestroyForce()
...

There are more, but these are all an apprentice triggerer really needs to know. There is a GUI action for removing a special effect, so we don't need to know the JASS function for that, units are removed from memory automatically once their corpses decay, and anything else is usually too rare to care about. If we are practical, the only thing we really need to care about are temporary handles that are created dynamically and rapidly, in triggers that run often or loop a lot. So what if a cinematic trigger that runs only once leaks a few locations? It's the tens of thousands of locations or unit groups that can leak on a fast periodic trigger that matter.

As has already been mentioned, to remove a temporary handle that has served it's purpose, we need to know where it is, we need to have a variable pointing to it. The only way to do that is to point a variable to it when we create it. For that, we first need some variables that we'll use for this purpose, in my examples I'll name them tempPoint and tempGroup. They are global variables that you define in the variable editor, and because of that they get the "udg_" prefix in JASS scripts.

Now, let's say we want to create a footman at the center of playable map area. If we didn't care about memory leaks, we would do it like this:

Unit - Create 1 Footman for (Player 1 - Red) at (center of (playable map area)) facing 0.00 degrees

However, the (center of (playable map area)) creates a location object at which the footman is then created, and this location then "leaks" because we can't remove it, because there's no way to know where in memory it is. We avoid this leak like this:

Set tempPoint = (center of (playable map area))
Unit - Create 1 Footman for (Player 1 - Red) at tempPoint facing 0.00 degrees
Custom script: call RemoveLocation( udg_tempPoint )

and similarly for everything else, let's say we want to kill all units in a region:
Set tempGroup = units in TheUnholyRegionOfVanillaFlavouredDoom <gen>
Unit group - pick every unit in tempGroup and do: Kill (picked unit)
Custom script: call DestroyGroup( udg_tempGroup )

That is about it concerning the basics of memory leaks. Remember not to worry about every petty detail, if you have an old map which you want to fix a bit, just clear the most critical special effect, unit group and location leaks and any noticeable problems with lag will be solved. On future maps, you can afford to be a bit more precise and thourough in hunting memory leaks.

One last note, it is said that destroying triggers after you no longer need them can be quite effective performance-wise, especially with long initialization triggers that run once and are then not used again. To do that, just put the following line at the end of the trigger.

call DestroyTrigger(GetTriggeringTrigger())
Thunder_eye is offline  
Old 09-29-2005, 06:13 AM   #8 (permalink)
Owner
 
Ralle's Avatar

WoW! StarCraft II
 
Join Date: Oct 2004
Posts: 6,116

Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)Ralle has disabled reputation (1524)


I learned something from that. Thanks! I will add it to the Tips & Tutorial section.
__________________
Info:
Ralle'sSigna-ture
Todo ListPM MeNews
Progress:
New Section
||||||||||
Ralle is offline  
Old 09-29-2005, 06:09 PM   #9 (permalink)
 
Thunder_eye's Avatar

User
 
Join Date: May 2004
Posts: 207

Thunder_eye has little to show at this moment (5)


Re: memory leaks

Always glad to help :)
btw Ive posted in you clan forum
Thunder_eye is offline  
Old 10-21-2005, 02:56 AM   #10 (permalink)
 
Earth-Fury's Avatar

Inside You <3
 
Join Date: Feb 2004
Posts: 545

Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)

PayPal Donor: This user has donated to The Hive. 

hmn, what other forms of temporary variables can be destroyed? ive know about destroying locations and unit groups for a long time now, but what else can be destroyed? (when makeing <<EPIC>> sized RP maps, conserving memory becomes extreamly important :))
Earth-Fury is offline  
Old 10-30-2005, 08:10 PM   #11 (permalink)
 
Thunder_eye's Avatar

User
 
Join Date: May 2004
Posts: 207

Thunder_eye has little to show at this moment (5)


units, doodads, destructibles, items, special effects and also regions, locations, unit groups, player groups are the ones that leaks.
Locations and unit groups leaks the most so those are the most importment ones to destroy.
Integer, Booleans and Reals are as I said just numbers that are erased automaticly
Thunder_eye is offline  
Old 10-31-2005, 05:25 PM   #12 (permalink)
 
The_Taxidermist's Avatar

No rly don't read it
 
Join Date: May 2005
Posts: 512

The_Taxidermist is on a distinguished road (79)The_Taxidermist is on a distinguished road (79)


This might be the problem with one of my maps. can someone well versed in memory leaks chekc it out and see it that is the problem?
Attached Files
File Type: w3x shootout_2__141.w3x (41.5 KB, 12 views)
__________________
The_Taxidermist is offline  
Old 11-01-2005, 12:43 PM   #13 (permalink)
 
Thunder_eye's Avatar

User
 
Join Date: May 2004
Posts: 207

Thunder_eye has little to show at this moment (5)


Ok I found some especially critical triggers.
Read through the post above and fix these triggers:
"respawn dead players"
All the ones in "Firing the gun"
"move"
"limits" (dont know how oftern this is used but add it anyway)
"explode1,explode2" (same with these two)
"kill player"
"ffa win"
Thunder_eye is offline  
Old 11-01-2005, 12:47 PM   #14 (permalink)
 
The_Taxidermist's Avatar

No rly don't read it
 
Join Date: May 2005
Posts: 512

The_Taxidermist is on a distinguished road (79)The_Taxidermist is on a distinguished road (79)


lol, thats pretty much all the maps triggers to fix then :lol:

Cheers, I'll get to work on that

EDIT: I've fixed "move" I'm guessing that was the most lethal since it was leaking 12 locations every 0.2 seconds :P
__________________
The_Taxidermist is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Trigger] Memory Leaks? Black-Templar Triggers & Scripts 12 11-21-2007 08:37 AM
Memory Leaks Jupiterstorm World Editor Help Zone 2 09-30-2007 05:12 PM
What exactly is the downside of memory leaks? Aoen Triggers & Scripts 16 02-05-2007 11:03 PM
Memory Leaks TheSonOfCulture World Editor Help Zone 2 11-05-2006 04:04 PM
[JASS] Memory Leaks USETHEFORKS Triggers & Scripts 1 11-02-2004 03:54 PM

All times are GMT. The time now is 04:39 AM.






Your link here 
Loans | Credit Cards | Loan | Prepaid Credit Cards | Web Advertising
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle