2 Memory Leak Questions

L

LucidWay

Guest
*I can't count: 3 ?'s*
Ok, so in the tutorial, it said these values cause memory leaks:
Points
Unit Groups
Player Groups
Special Effects
Strings
Regions

Question #1:
No other data types cause leaks? Local integers from functions etc....?

Question #2:
If I have a loop where i redefine a leaking data type, do I only have to remvoe that variable once?
Ex:
Code:
local group TempGroup
loop
      exitwhen (XXX)
      set TempGroup = YYY
endloop
call DestroyGroup(TempGroup)

Question #3
If I have a global group arrary (Groups leak), and want to use that global group in a trigger. Do I need to make a local group with the specific array group then delete that?
Ex:
Code:
    set TempGroup = udg_GlobalGroup[X]
    set TempUnit = GroupPickRandomUnit(TempGroup)
    call DestroyGroup(TempGroup)

Thanks a bundle.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Numbers don't leak.
Which includes integer, real and boolean.
Strings are handled slightly differently, but there's nothing you can do there anyway.


Every time you create a group, you also need to destroy it.
Especially if it is local.
You also need to "set variable = null" once done with the group.


Q3 is a bit unclear...

> set TempGroup = udg_GlobalGroup[X]

This will not make a copy of that group.
You might just as well use the array one.
 
L

LucidWay

Guest
thanks
You also need to "set variable = null" once done with the group.
You mean i need to do this in the loop? Do I also need to do this with other variables in a loop or just leaking ones?

Thanks
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
local group g = CreateGroup()

...do somthing with it...

call DestroyGroup(g)
set g = null

You only need this once, after being completely done with the variable.
And, yes, using "set myInteger = 0" is just a waste of time...
 

emjlr3

Change can be a good thing
Reaction score
395
unless ofcourse u create a new group each time, in which case u need to destroy the last, but it only needs to be nulled once
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top