how do i remove Memory Leaks from my map?

Shlomi1515

New Member
Reaction score
2
it's happen to me randomly all the players get DC at the same time
i search in forums and they said i have memory leaks in my map
and I wonder how do i know what is a memory leak and how to prevent/remove all the memory leaks in the map?

thanks
 

hopy

Active Member
Reaction score
64
http://www.thehelper.net/forums/showthread.php?t=27219&highlight=memory+leak+guide

That's a guide for memory leaks.

They're basicly variables and stuff that are placed in your memory in a trigger but don't get removed... so afther a while your memory will be full of data that isn't being used and doesn't get removed.
You have to save ALL points you use in a variable.
Trigger:
  • Actions:
    • Set Temp_Point = Position of (Triggering Unit)

To remove these you'll need to place stuff like:
Trigger:
  • Actions:
    • Custom script: call RemoveLocation (udg_Temp_Point)


Keep in mind that:
Trigger:
  • Actions:
    • Set Temp_Point = Position of (Triggering Unit) offset by 200 towards 90 degrees
    • Custom script: call RemoveLocation (udg_Temp_Point)

Is still a leak, Position of (Triggering Unit) is a Point.
Trigger:
  • Actions:
    • Set Point = (Position of (Triggering Unit)
    • Set Temp_Point = Position of (Triggering Unit) offset by 200 towards 90 degrees
    • Custom script: call RemoveLocation (udg_Temp_Point)


Stuff that leaks:
Special Effects
Groups
Points
Units
Regions
Forces
Lightning Effects
Floating Text
Countdown Timers
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
memory leaks do not cause disconnections.

what causes disconnections for certain players only are desyncs, mostly connected to GetLocalPlayer comparisons.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, they crash the game completely for every player, not just disconnect single players :p
 

Shlomi1515

New Member
Reaction score
2
I do have a level that have endless loops that I call "game over" it stops when the game finish and the last player stand wins....

i dont have a lot of what u said about the memry leaks..

Special Effects - None

Groups - i need the groups very much there is no game without it... is taking alot of memory?

Points - None

Units
- there is a wondeful trigger "Unit Died - Remove Unit From The Game!

Regions
- using variable as region is size is 8 Region [8] each number is the location of the player number it's a golbal variable

Forces - only 2

Lightning Effects - no by trigger only by unit

Floating Text - only 4 in my map 3 o them i remove after voting

Countdown Timers - only a timer window that start everytime before level
but the triggers destory it and recreate it again when needed....


can u find the most problem of it plz do tell....
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
i think you dont know what a memory leak is.

basically you use variables to have control about certain objects.
for example you have a unit group object, but you cannot give it any orders nor ask it something because you dont know whom to ask.
thats why you say, this unit group is MyUnitGroup < a variable.
now you can give it orders like "add unit" or "clear" or whatever or you can ask it for all units inside etc.
if you use these variables in the editor and do something like this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))

you are creating a unit group, and setting the variable MyUnitGroup to that last created group.
the variable itself doesnt take any memory but the unit group does! (well, the variable takes a little, but thats not even noticeable with billions of them)
but thats normal, you can prevent it. you want to have units saved within a unitgroup and therefor you need to use some of your memory to save them.

a memory leak happens when you do this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))
    • set MyUnitGroup = All units owned by (Player 2 (Red))
    • set MyUnitGroup = All units owned by (Player 3 (Red))

what happens now is that you create 3 unit groups but at the end of the trigger the variable MyUnitGroup is set to only the last one of them.
The other 2 groups do still exist but you have now no control over them anymore.
that means that they still take memory though you are not able to remove them anymore to get the memory back.
but if you do this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))
    • custom script: call DestroyGroup (udg_MyUnitGroup)
    • set MyUnitGroup = All units owned by (Player 2 (Red))
    • custom script: call DestroyGroup (udg_MyUnitGroup)
    • set MyUnitGroup = All units owned by (Player 3 (Red))

the 2 unitgroups will be destroyed and thus no longer take memory.


you have to remove leaks from points, rects, unitgroups, forces, etc when you re-set the variable. if you set it somewhere and never change it thats fine. memory leaks is basically like garbage which cannot be used anymore because you cannot adress it. thats what you have to remove.

and by the way, unit variables do not leak because units are removed from the game automatically when they die.
 

Shlomi1515

New Member
Reaction score
2
i think you dont know what a memory leak is.

basically you use variables to have control about certain objects.
for example you have a unit group object, but you cannot give it any orders nor ask it something because you dont know whom to ask.
thats why you say, this unit group is MyUnitGroup < a variable.
now you can give it orders like "add unit" or "clear" or whatever or you can ask it for all units inside etc.
if you use these variables in the editor and do something like this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))

you are creating a unit group, and setting the variable MyUnitGroup to that last created group.
the variable itself doesnt take any memory but the unit group does! (well, the variable takes a little, but thats not even noticeable with billions of them)
but thats normal, you can prevent it. you want to have units saved within a unitgroup and therefor you need to use some of your memory to save them.

a memory leak happens when you do this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))
    • set MyUnitGroup = All units owned by (Player 2 (Red))
    • set MyUnitGroup = All units owned by (Player 3 (Red))

what happens now is that you create 3 unit groups but at the end of the trigger the variable MyUnitGroup is set to only the last one of them.
The other 2 groups do still exist but you have now no control over them anymore.
that means that they still take memory though you are not able to remove them anymore to get the memory back.
but if you do this:
Trigger:
  • set MyUnitGroup = All units owned by (Player 1 (Red))
    • custom script: call DestroyGroup (udg_MyUnitGroup)
    • set MyUnitGroup = All units owned by (Player 2 (Red))
    • custom script: call DestroyGroup (udg_MyUnitGroup)
    • set MyUnitGroup = All units owned by (Player 3 (Red))

the 2 unitgroups will be destroyed and thus no longer take memory.


you have to remove leaks from points, rects, unitgroups, forces, etc when you re-set the variable. if you set it somewhere and never change it thats fine. memory leaks is basically like garbage which cannot be used anymore because you cannot adress it. thats what you have to remove.

and by the way, unit variables do not leak because units are removed from the game automatically when they die.

i do understand but i do not have such thing in my game.... i have 8 groups and i need every one of them till the game ends... i dont need to remove it
 

X-maul

AKA: Demtrod
Reaction score
201
the problem is that you dont have that stuff in your map - if you create a trigger action which calls something, like a point in a region, you create a memory leak if you do not destroy it like described above.
 

hopy

Active Member
Reaction score
64
i do understand but i do not have such thing in my game.... i have 8 groups and i need every one of them till the game ends... i dont need to remove it

What they're trying to tell you is that every Point, Unit Group, special effect etc. needs to be destroyed as soon as you're done with it. Destroying it doesn't mean that you cant use the variable anymore, it just removes its data from your memory so that it's empty and can be used again.

Take for example: This is your 4 slot memory:
[]
[]
[]
[]
It's empty now.
Now you have this ability:
Trigger:
  • Kill everything
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kill everything close
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set Unit_Group = (Units within 500.00 of Point matching (((Matching unit) has buff Pmgwtf) Equal to True))
      • Unit Group - Pick every unit in Unit_Group and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)

When you use it your memory looks like:
[Point]
[Unit_Group
[]
[]
Afther you use it again it would become:
[Point]
[Unit_Group
[Point]
[Unit_Group]
It's full, you get lag and dc and stuff.
You "destroy" this data so that afther it's not needed anymore (Afther the ability is cast and everything has been killed) it's removed and doesn't take space. When you cast the ability again it will give new data to Unit_Group and Point and once it's done it will be removed again.

So the variable doesn't get destroyed, only the data in it so that when you cast it again it can be done without wasting space afther every cast.
Trigger:
  • Kill everything
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kill everything close
    • Actions
      • Set Point = (Position of (Triggering unit))
      • Set Unit_Group = (Units within 500.00 of Point matching (((Matching unit) has buff Omgwtf) Equal to True))
      • Unit Group - Pick every unit in Unit_Group and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Custom script: call RemoveLocation (udg_Point)
      • Custom script: call DestroyGroup (udg_Unit_Group)

Tada, leakfree, the ability works everytime you use it but doesn't take any space on the memory afther being used (as little as posible in GUI, yes, yes Accname we know :D).
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
any variables which are not set again, like the groups you mentioned which you need until the games end, do not need to be destroyed nor removed. they do not leak.
 

Shlomi1515

New Member
Reaction score
2
Thanks so much hopy ;p

And what do I write in the Custom script if my variable got array

any variables which are not set again, like the groups you mentioned which you need until the games end, do not need to be destroyed nor removed. they do not leak.

That's what im trying to say the groups been created with "Map initialization"
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
if you set udg_MyUnitGroup[1]
you have to destroy udg_MyUnitGroup[1]
simple as that.

for example:
Trigger:
  • set Point[0] = (Center of (Playable Map Area))
    • custom script: call RemoveLocation (udg_Point[0])
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top