Triggers - Memory Leaks and Custom Scripts

Tzirrit

New Member
Reaction score
7
That's what i have feared. So i'd have to save that random point in a variable and either destroy it afterwards, or just keep overwriting it with new random positions.. because i use that quite often for wandering creeps, patroling npcs and so on? Great.. lots of klicking to be done ;(
 

quraji

zap
Reaction score
144
You need to save it in a variable and destroy it, every time you use it. Points don't remove themselves from memory just because you stored a new one in the variable.
 

Tzirrit

New Member
Reaction score
7
Ok, i wasn't sure about this, thought overwriting would be enough. Thanks for making it clear.

edit: finally.. my map should be leak free.. didnt even take as long as i thought (zomg - only 4 hours) and i optimizied some triggers while i was at it. +rep for this nice tut that made me do it *g*
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
I didn't read all of the tutorial, but I skimmed through... Nice job, but I have a question:

Do you have to always set a variable as a point and then place the special effect or is it ok if you use things such as regions or coordinates? :D

Nice tutorial... +rep :D
 

emjlr3

Change can be a good thing
Reaction score
395
reals dont leak, locations of regions do
 
B

Banana

Guest
I'm wondering why do we need to call functions to clear leaks. Wouldn't setting the variable to null or nothing or something similar accomplish this without calling a function?
 
N

Niko

Guest
i read somewhere else that random numbers can leak... but that would be included in the reals/ints etc correct? so i'm assuming they don't because i use an integer variable for most of my random numbers. just checking!
thanks
niko

PS almost forgot... sometimes i have conditions that check the distance between the positions of two units... do these checks require a variable. I'm guessing the game doesn't actually store anything so i would assume there are no memory problems in conditions
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
@emjlr3: Thanx!

@Banana: Not always nulling can clear leaks, you must perform other functions or actions etc. as well to stop it:
eg: call RemoveLocation( a )

@Niko: Nope, reals and integers don't leak as emjlr3 said... Random Numbers are included as int/real.
For the second problem, I guess you could store it as a variable (Here is it in GUI):
Code:
set Distance = (Distance between <blablb> and <ballablbalbla>)
But I don't know if it is actually necessary. ;)
 
S

shadowvzs

Guest
i dont know this not leakable if i kill under 1 sec 10 creep? because 10 special effect and 1 removing but variable overwrited, or how will be this?
Code:
reSpawn
    Events
        Unit - A unit owned by Neutral Hostile Dies
        Unit - A unit owned by Player 11 (Dark Green) Dies
    Conditions
        ((Triggering unit) is Summoned) Equal to False
        ((Triggering unit) is A structure) Equal to False
        (Unit-type of (Triggering unit)) Not equal to Chocobo
    Actions
        Custom script:   local item ItemA
        Set Tempory_nr[26] = (Random integer number between 1 and 100)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Tempory_nr[26] Less than or equal to item_drop_rate
            Then - Actions
                Item - Create (Random level (Random integer number between 0 and 10) Purchasable item-type) at ReSpawnPoint
                Custom script:   set ItemA = bj_lastCreatedItem
            Else - Actions
        Set ReSpawnPoint = (Position of (Triggering unit))
        Special Effect - Create a special effect at ReSpawnPoint using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadDissipate.mdl
        Custom script:   call RemoveLocation(udg_ReSpawnPoint)
        Set SpecialEffect[0] = (Last created special effect)
        Wait 3.00 seconds
        Custom script:   call DestroyEffect (udg_SpecialEffect[0])
        Wait 40.00 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ItemA Not equal to No item
                (ItemA is owned) Not equal to True
            Then - Actions
                Custom script:   call RemoveItem(ItemA)
                Custom script:   set ItemA = null
            Else - Actions
        Wait (((Real((Level of (Triggering unit)))) + 1.00) / 2.00) seconds
        Set ReSpawnPoint = ((Center of (Entire map)) offset by (CreepX[(Custom value of (Triggering unit))], CreepY[(Custom value of (Triggering unit))]))
        Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at ReSpawnPoint facing Default building facing degrees
        Custom script:   call RemoveLocation(udg_ReSpawnPoint)
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
        Animation - Play (Last created unit)'s birth animation
 

SerraAvenger

Cuz I can
Reaction score
234
emjlr3 said:
Memory Leak: the leakage of handle objects, or in other words, basically whenever you create something or reference something, other than integers the game loses it’s location, thus causing a leaked piece of memory. Now granted these are cleaned at the end of the game, but if enough pile up during play without being removed, it can cause serious lag to the players, ranging from a little here and there, to complete un-playability, neither of which is wanted.

I would descipt it as:
SerraAvenger said:
Memory Leak:
A memory leak occurs, when you loose the last pointer to an object that actually uses memory. As you can no longer refer to that object then, you cannot destroy and so you cannot free the memory you allocated by creating it. This memory can no longer be used, so you have small to great perfomance losses.
Note that as long you still can refer to the object (due to variables or functions), the memory it occupies will not leak. Still, you should destroy every object as soon as you no longer need it; saving in variables will need even more memory than a simple memory leak. Still you can free the memory and reduce the needed ressources.

You mainly seperate between 2 forms: Normal leaks, and Bad leaks. A bad leak is a leak that happens multiple times (in a loop , in a trigger fireing very often ). Normal leaks are such that only occur once ( In a trigger on map initiallisation creating a point for A unit that shall patrol to that point ).

Memory leaks only at the moment you loose the last pointer to the object allocating it, not before and not after. And an object ( location, p.e. ) cannot leak. It is the memory that does, and an object cannot have a leak, it is the code that has.
Longer, but more correct and informative.
Would remove some great missunderstandings, too.
Greetings, Serra


EDIT:
@Shadowvyz:
Yes it will leak. Set it to a local variable instead.
 
O

Object

Guest
Interesting... it makes me wonder why they did not just build these solutions into the GUI triggers... :nuts:
 

SerraAvenger

Cuz I can
Reaction score
234
Interesting... it makes me wonder why they did not just build these solutions into the GUI triggers... :nuts:

The same reason for doing this crap:
Code:
DestroyCondition
DestroyBoolExpr
DestroyDamageOptions
DestroyDefeatCondition                                      
DestroyEffect
DestroyFilter
DestroyForce
DestroyLightning
DestroyGroup
DestroyImage
DestroyLeaderboard
DestroyMultiboard
DestroyQuest
DestroyTimer
DestroyTextTag
DestroyUbersplat
But
Code:
RemoveLocation
- I would call it inattention and lazyness...
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
I have a question that I've been eager to ask.
Does the custom script DESTROYS the variable or EMPTIES it?
So if we have (for example) several point leaks in different triggers, do we have to create another variable or use the previous point variable?

Hi anyway, I'm new here, but not to WE
 
S

Sunny_D

Guest
if you mean variables that you define within the trigger editor (global variables), then you still can use the variable itself for later other points. so in your words - it "empties" the variable.

example, you create a point variable TempLoc that you can use for all your leak-removings in your triggers - as long as you dont have waits in between, but thats of course another story.

Set TempLoc = ...
Unit - create Unit at TempLoc // or whatever else..
Custom script - call RemoveLocation (udg_TempLoc)

you can use the TempLoc variable again and again that way :)

PS: ye, i know its late, but meanwhile no1 else answered and i saw you edited your post just yesterday, so.... :D
 
A

AK-47Pirates

Guest
I used Tinki3's creep revival system, and in my RPG, I'd figure it is gunna leak several hundred times, but I don't know how to even begin fixing this leak:

Code:
Creep Revival System Initialization
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
            Loop - Actions
                Set Integer = (Integer + 1)
                Unit - Set the custom value of (Picked unit) to Integer
                Custom script:   set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
                Custom script:   set udg_Creep_Y[udg_Integer] = GetUnitY(GetEnumUnit())

Code:
Reving Creeps 1 By 1
    Events
        Unit - A unit Dies
    Conditions
        ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    Actions
        Wait 60.00 game-time seconds
        Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at ((Center of (Entire map)) offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))])) facing (Random angle) degrees
        Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))

How would I do this?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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