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.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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