HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Memory Leak Clarification

02-28-2009, 12:19 AM#1
ShadowWolf
Okay, so referencing a location such as "Center of Region" leaks. The typical solution to this is:
Trigger:
Actions
Set Temp_Loc = (Center of Pasture <gen>)
Unit - Order (Entering unit) to Move To Temp_Loc
Custom script: call RemoveLocation(udg_Temp_Loc)
From start to finish, that code fires about 2708 times, and 404 of those executions happen simultaneously. Assigning that variable and removing it everytime when it fires seems a bit excessive, so what's the best way to handle the leak? Would assigning that location variable at the start of the map then referencing only to that variable without clearing it still leak?
02-28-2009, 12:33 AM#2
Zerzax
Learn JASS so you only have to use Loc's for terrain Z. I can't say more atm, but I'll edit the post later.
02-28-2009, 12:38 AM#3
akolyt0r
Quote:
Originally Posted by ShadowWolf
Assigning that variable and removing it everytime when it fires seems a bit excessive, so what's the best way to handle the leak? Would assigning that location variable at the start of the map then referencing only to that variable without clearing it still leak?

You could perhaps leak that one location ...but that doesnt matter at all ..its ..dunno ...4bytes ?
02-28-2009, 12:45 AM#4
ShadowWolf
Wouldn't it leak every time that trigger fires?
02-28-2009, 12:46 AM#5
Kyrbi0
I'm not sure it's "excessive". That seems like proper protocol for Localizing the global variable, so... What's the beef?
02-28-2009, 12:51 AM#6
ShadowWolf
Assigning a variable and removing it 400 times instantaneously is what seems excessive.
02-28-2009, 12:56 AM#7
akolyt0r
Quote:
Originally Posted by ShadowWolf
Assigning a variable and removing it 400 times instantaneously is what seems excessive.

hmm ..wont do any harm ...only thing could be thread crash due to op limit hit... but i think that may take more than 400 times that shit ..to reach the limit
02-28-2009, 12:58 AM#8
Kyrbi0
Well, it all depends on how "instantaneously" it really is.

AFAIK, a trigger runs through a whole time, with no interruptions. So even if it does it 400 times consecutively, that's cool; it's what it's meant to do.

Also, what in the world is doing that to a location so many times??
02-28-2009, 01:14 AM#9
Captain Griffen
If you can still access and are still using the location, it is not actually leaked. Cached would be a better word.
02-28-2009, 01:16 AM#10
Blacktastic
I'm curious to know what exactly that's for as well o.o
02-28-2009, 01:49 AM#11
Strilanc
Quote:
Originally Posted by ShadowWolf
... From start to finish, that code fires about 2708 times, and 404 of those executions happen simultaneously. Assigning that variable and removing it everytime when it fires seems a bit excessive, so what's the best way to handle the leak? Would assigning that location variable at the start of the map then referencing only to that variable without clearing it still leak?

Let me assure you that the unit order is by far the most expensive call there. The assignment and cleanup are jokes in comparison.