Memory leaks

S

Shades-X

Guest
I am new to the whole memory leakage thing... so I have been reading tutorials to help find where memory leaks could be in my map... so far I found 5 possible memory leak spots here they are:

#1
Code:
Trap1
       Events -
            Time - Every 2.5 seconds of game time

       Conditions - none

       Actions -
            Unit - Create 1 Trap for Player 12(Brown) at (Center of Trap1<gen>) facing 0.00 degrees
            Unit - Order (Last created unit) to Move to (Center of Trap 1<gen>)

#2
Code:
Trap2start
       Events -
            Unit - A unit enters Trap2<gen>

       Conditions -
            (Unit type of (Triggering unit)) Equal to Rat

       Actions -
            Special Effect - Create a special effect at (Center of Trap2start<gen>) using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
            Unit - Create 1 Chomper for Player 12(Brown) at (Center of Trap2start<gen>) facing 270.00 degrees
            Unit - Order (Last created unit) to Move to (Center of Trap2<gen>)
            Wait - 0.50 seconds
            Special Effect - Destroy (Last created special effect)

#3
Code:
Trap2finish
       Events -
           Unit - A unit enters Trap2finish<gen>

       Conditions -
           (Unit type of (Triggering unit)) Equal to Chomper

       Actions -
           Unit - Remove (Triggering unit) from the game
           Special Effect - Create a special effect at (Center of Trap2finish<gen>) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
            Wait - 0.50 seconds
            Special Effect - Destroy (Last created special effect)

#4
Code:
Health
        Events -
            Time - Every 2.50 seconds of game time

        Conditions - none

        Actions -
             Set hitpoints = (Life of Rat 0008<gen>)
             Unit - Set life of Rat 0008<gen> to (hitpoints - 5.00)

#5
Code:
Hunger Death
        Events -
            Unit - A unit dies

        Conditions -
            (Unit type of (Triggering unit)) Equal to Rat
            (Unit type of (Killing unit)) Not equal to Rat poison

        Actions -
            Game - Game display to (Player group((Owner of (Triggering unit)))) the text: |c00330000GAME OVER...|r
            Sound - Play laugh<gen>
            Wait - 3.00 seconds
            Sound - Destroy (Last played sound)

All I wish to know is... Are these memory leaks and what custom scripts will be needed to fix them.
 
D

Dino.pl

Guest
#4: Reals, integers, booleans, strings (and codes?) don't leak.

#1-3 have location leaks.
You can fix then that way (an example on #2):
Code:
[COLOR=Green]    set temploc (a location aka point type variable) = Center of Trap2start<gen>
    set temploc2 (another location type variable) = Center of Trap2<gen>[/COLOR]
    Special Effect - Create a special effect at ([COLOR=Green]temploc[/COLOR]) using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
    Unit - Create 1 Chomper for Player 12(Brown) at ([COLOR=Green]temploc[/COLOR]) facing 270.00 degrees
    Unit - Order (Last created unit) to Move to ([COLOR=Green]temploc2[/COLOR])
[COLOR=Green]    custom script: call RemoveLocation(temploc)
    custom script: call RemoveLocation(temploc2)[/COLOR]
    Wait - 0.50 seconds
    Special Effect - Destroy (Last created special effect)
#5 has a player group leak.
It can be fixed the same way:
Code:
[COLOR=Green]    set tempforce (a force aka player group variable) = Player group((Owner of (Triggering unit)))[/COLOR]
    Game - Game display to ([COLOR=Green]tempforce[/COLOR]) the text: |c00330000GAME OVER...|r
[color=green]    custom script: call DestroyForce(tempforce)[/color]
    Sound - Play laugh<gen>
    Wait - 3.00 seconds
    Sound - Destroy (Last played sound)
Also note that if another Rat dies within this 3-sec wait, the second played sound will be destroyed twice and the first won't be destroyed. Similar problem is with #2 and #3.
 

SFilip

Gone but not forgotten
Reaction score
634
#2 and #3:
Code:
Special Effect - Create a special effect at (Center of Trap2finish<gen>) using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
Wait - 0.50 seconds
Special Effect - Destroy (Last created special effect)
the wait is completely unneccesary. most of the special effects are technically over instantly. so if you create it and then destroy it right after that you will still see the effect...and its better that way because it just might happen that you create some other effect within those 0.5 seconds (although hardly possible).
anyway leaks are usually something like Center of <region>, Position of <unit>, All units in <region>, All units of Type, All players matching condition etc.
basically every time you use a point or a unit/player group that isn't a variable, it leaks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top