retupmoc258
New Member
- Reaction score
- 1
I am very curious about memory leaks. Currently I am working on a map and while I see some places where memory leaks can occur, I still can't explain why the memory used for my map grows by about 500KB per second. That's ridiculously fast when nothing is being spawned and obviously causes lags within about 60 seconds of gameplay.
So here's my questions. Local Variables, do they leak? For example, I have a function with three local variables: Location, Group, Unit.
My understanding of functions, at least as they work in other programming code, is that a local variable is whiped from memory when the function is no longer being used, regardless of type.
Now I know whenever you use a function that creates a group, that group is registered independent of the function, correct? And the local variable is simply a reference for that object. The same is true of locations and units. The object remains in play until it is removed in some fashion (death works for a unit, but a location needs to be removed and a group destroyed, correct?)
So, if I have a function that creates a group for a local variable and destroys it when it's done, do I have to se the group variable to null? Similarly, with a unit, if I get a unit from say "GetSpellAbilityUnit()", do I need to set that unit variable to null before the function leaves? The unit still exists independent of my local variable, so I wonder if that leaks by storing memory after the function quits. I similarly remove my unneeded locations when I'm done with them.
So then this comes back around to the local variable idea. If I have a location, say LocationA and I have two local variables, loc1 and loc2. Then I do the following:
set loc1 = LocationA
set loc2 = LocationA
Then those are both just references, right? There's no real memory stored for them, and when the function quits loc1 and loc2 will be nulled, but the LocationA, which exists independent of the function, will still be in memory, correct? If I call "RemoveLoc(loc1)" then I actually remove LocationA, right? I know this is how it works with a unit. If I say "KillUnit" it doesn't kill the variable, it kills the unit it was referencing. Am I still on the right track?
Now, some of my triggers are currently in GUI, and a few I know cause leaks, but they are not referenced very often (and if they were, I would know about it because it tells me if it runs while WC3 is running).
But still, for some reason my memory is growing nearly 500KB per second, and it doesn't seem to stop no matter how long the map is running.
I was also wondering if someone would mind taking a look at my map triggers to see if they could identify where the memory problem is coming from. I do use a couple hashtables, including one that uses indexes of any unit that meets the requirements and changes values. But, I can't imagine this being the cause of a continual growth since I use the index values that never change for units that are not growing in number. Is there anyone who would be willing to take a look at it?
So here's my questions. Local Variables, do they leak? For example, I have a function with three local variables: Location, Group, Unit.
My understanding of functions, at least as they work in other programming code, is that a local variable is whiped from memory when the function is no longer being used, regardless of type.
Now I know whenever you use a function that creates a group, that group is registered independent of the function, correct? And the local variable is simply a reference for that object. The same is true of locations and units. The object remains in play until it is removed in some fashion (death works for a unit, but a location needs to be removed and a group destroyed, correct?)
So, if I have a function that creates a group for a local variable and destroys it when it's done, do I have to se the group variable to null? Similarly, with a unit, if I get a unit from say "GetSpellAbilityUnit()", do I need to set that unit variable to null before the function leaves? The unit still exists independent of my local variable, so I wonder if that leaks by storing memory after the function quits. I similarly remove my unneeded locations when I'm done with them.
So then this comes back around to the local variable idea. If I have a location, say LocationA and I have two local variables, loc1 and loc2. Then I do the following:
set loc1 = LocationA
set loc2 = LocationA
Then those are both just references, right? There's no real memory stored for them, and when the function quits loc1 and loc2 will be nulled, but the LocationA, which exists independent of the function, will still be in memory, correct? If I call "RemoveLoc(loc1)" then I actually remove LocationA, right? I know this is how it works with a unit. If I say "KillUnit" it doesn't kill the variable, it kills the unit it was referencing. Am I still on the right track?
Now, some of my triggers are currently in GUI, and a few I know cause leaks, but they are not referenced very often (and if they were, I would know about it because it tells me if it runs while WC3 is running).
But still, for some reason my memory is growing nearly 500KB per second, and it doesn't seem to stop no matter how long the map is running.
I was also wondering if someone would mind taking a look at my map triggers to see if they could identify where the memory problem is coming from. I do use a couple hashtables, including one that uses indexes of any unit that meets the requirements and changes values. But, I can't imagine this being the cause of a continual growth since I use the index values that never change for units that are not growing in number. Is there anyone who would be willing to take a look at it?