General - Reducing Lag

ragingspeedhorn

Is a Banned Asshole
Reaction score
94
Darthfett said:
Is it the color, or just the fact that they're big and in the way? :p

I'll try and make it more readable. Thanks for the feedback! :)

The color, it's annoying for the eyes, would prefer it in black and then you could always make it bold or something if you want it more highlighted :)
 
Reaction score
65
Code:
Events
    Unit - A unit enters Region 0001 <gen>
Conditions
Actions
    Unit - Create 1 Footman for Player 1 (Red) at ((Position of (Entering Unit)) offset by 50 towards 90 degrees) facing Default building facing degrees

It looks like one leak, right? But there are actually 2 leaks here; Position of (Entering unit) leaks, but so does the point created by offsetting it.

Oh, that's the thing causing the lag in my map! Thank you, +rep! :)
 
P

phenophae

Guest
great tutorial.

But I am still a little fuzzy on regions. I am assuming this is ok:

Code:
Trigger
    Events
        Unit - A unit enters Creep1 <gen>
    Conditions
        ((Triggering unit) belongs to an ally of Player 12 (Brown)) Equal to True
    Actions
        Unit - Order (Triggering unit) to Attack-Move To (Center of Creep2 <gen>)

And this is ok too:

Code:
For each (Integer A) from 1 to Crab_Array_Waves[Number_of_Players], do (Actions)
    Loop - Actions
        Unit - Create Creep_Per_Player[Number_of_Players] Creep_Array[WaveCount] for Player 12 (Brown) at (Center of CreepSpawn1 <gen>) facing Default building facing degrees
        Wait 1.00 seconds

My main concern is creating a creep at the Center of a region. Will this leak because it is a center point? or is this ok because I defined the region, CreepSpawn1 <gen>? I am assuming its a possible leak because I am using the "center point" of this region. :confused:

Thanks for the help. Great tutorial.
 

Chocobo

White-Flower
Reaction score
409
Now you have made it so that you can destroy the leak. Each leaking variable has its own custom script to destroy it however, so you must memorize these lines:

You do not need to destroy a leak from a global variable, because you may override it later, and so it destroys its old value.


Another type of variable that leaks is a Region, but unless the region is not a default region (Playable Map Area), or a Preplaced region (Region XXXX <gen>), it will not leak. However the custom script to destroy a region is:

Custom script: call RemoveRect(udg_*Temp variable name here*)

A Region is not equal to a Rect. But it is referenced as Region in References, and not as Rect, whereas it does a Rect.


A. Units

Again, everytime a unit or hero is created, the game has to load the unit. You can reduce the in-game lag by preplacing all the units, and as soon as the game starts, remove the units. Even dummy casters should be preloaded, otherwise when the first time an ability is cast, it will lag.

B. Abilities

If you add any abilities to units, then you should also create a special unit, that already has the abilities, just for preloading. Just preplace this unit, and remove it as soon as the map initializes. Make sure you preload spellbooks, as they will lag the most if not preloaded.

A : Yes, it will preload.

B : No, it must work for each unit that is able to have the ability.


An another part you should add about this :
Code:
call Preload( <string path>)

You will see it is helpful, it is able to preload .blp, .mdx, .tga .... and anything :p , but can only run at Map Initalization, and for imported files.

So does :

Code:
call PreloadEnd( <a real timeout>)
call PreloadEndEx
call Preloader( <string path>)
call PreloadGenClear
call PreloadGenEnd( <string path>)
call PreloadGenStart
call PreloadRefresh
call PreloadStart


-----New Sections Coming...-----
-Massive Amounts of Objects
-Nullifying Local Variables

Nullifying locals is already done in the tutorial.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
phenophae said:
great tutorial.

But I am still a little fuzzy on regions. I am assuming this is ok:

Code:
Trigger
    Events
        Unit - A unit enters Creep1 <gen>
    Conditions
        ((Triggering unit) belongs to an ally of Player 12 (Brown)) Equal to True
    Actions
        Unit - Order (Triggering unit) to Attack-Move To (Center of Creep2 <gen>)

This is not ok, because you use the point variable Center of (Region).

Your region is fine though, since it is already created/preplaced.

phenophae said:
And this is ok too:

Code:
For each (Integer A) from 1 to Crab_Array_Waves[Number_of_Players], do (Actions)
    Loop - Actions
        Unit - Create Creep_Per_Player[Number_of_Players] Creep_Array[WaveCount] for Player 12 (Brown) at (Center of CreepSpawn1 <gen>) facing Default building facing degrees
        Wait 1.00 seconds

My main concern is creating a creep at the Center of a region. Will this leak because it is a center point? or is this ok because I defined the region, CreepSpawn1 <gen>? I am assuming its a possible leak because I am using the "center point" of this region. :confused:

Thanks for the help. Great tutorial.

Again, you leaked a point variable because it is taking the center point of a Region. Your region is fine, again because it is already created/preplaced.

You do not need to destroy a leak from a global variable, because you may override it later, and so it destroys its old value.

Yes you do need to destroy a leak from a global variable. If you don't, and it is overwritten, then it is left in the memory, and you have no way to reference to it. The variable basically just points to the actual value stored in your memory, it is not the actual value itself, just a variable that points to it.

Chocobo said:
B : No, it must work for each unit that is able to have the ability.

If you add any abilities to units, then you should also create a special unit, that already has the abilities, just for preloading.

The ability itself is the only thing that has to be preloaded. You don't have to preload each unit that could have the ability added during the game, with the ability on it, just the ability itself. What lags is that the game has to load the ability when it is added.

Chocobo said:
An another part you should add about this :

Code:
call Preload( <string path>)

Thanks for the tip, i'll add it in. :)

Chocobo said:
Nullifying locals is already done in the tutorial.

Yes, that is an old post. I'll edit it. :p
 
C

Capt Griffen

Guest
Nulling strings is pointless. Once a string is created, the leak is permament (though don't remain after loading) - it is an engine optimisation, triggers can't control it.
 

Chocobo

White-Flower
Reaction score
409
Nulling strings is pointless. Once a string is created, the leak is permament (though don't remain after loading) - it is an engine optimisation, triggers can't control it.

Nope. A string takes ever at least 1 bit, but everytime you add substring, it increase by 4 bytes the total amount taken.
 
C

Capt Griffen

Guest
Nope. A string takes ever at least 1 bit, but everytime you add substring, it increase by 4 bytes the total amount taken.

String variables are not objects. They are 4 byte pointers which point to indexed strings in the engine. Those indexed strings are the 'leaks' - they cannot be removed in game. Every unique string generates one, and is assigned an index, which is what the string variable is (the pointer).

The total amount taken for each string variable is 4 bytes, but for each new unique string, some more memory is also permamently used up. It amounts to ~0.22kb I believe for an 8 character string, though my memory could be failing me a bit as I did the tests a long time ago.

Basically, it uses a similar system to handles, but the string objects don't ever get destroyed.
 
R

Recruit0

Guest
That looks like it would leak. It's using a point directly instead of a variable. I'm not entirely sure since I'm new at this :)

Question:
I have a trigger that checks if the someone selected a hero by entering a region. Should I remove this trigger later on (like after 3 minutes) to reduce lag? Also how do I reference triggers in JASS/custom script?

P.S. Awesome tutorial! *bows*
 
S

shadowvzs

Guest

when i use
Code:
call DestroyGroup (udg_*Temp variable name here*)
why i have errors?
this is my trigger
Code:
Set Activ_players = (All players controlled by a User player)
Player Group - Pick every player in Activ_players and do (Actions)
    Loop - Actions
        Dialog - Show Nation_question for (Picked player)
Custom script:   call DestroyGroup(udg_Activ_players)
if i use DestroyForce then i dont have error.... why?
 
F

Fame.

Guest
Theres been a problem.. even when i did all that use the optimizer and fixed the leaks.. my map still lags.. it lags really bad.. and i know its not my connection because when i host any other map its fine.. :(
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Theres been a problem.. even when i did all that use the optimizer and fixed the leaks.. my map still lags.. it lags really bad.. and i know its not my connection because when i host any other map its fine.. :(

Do you have Massive Amounts of Objects, and are you preloading everything?

Even having the camera zoomed out counts as having Massive Amounts of Objects.
 
G

gurra_geban

Guest
Does the "Wander" ability leak? I think ive removed all memory leaks in my city simulator map but it still laggs like hell after two hours... The only thing i can come up with is that the Wander ability leaks, because ive got tons of units using that ability...

Gr8 tutorial btw =)

bump
 
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