Question About Memory Leaks

crabbb622

New Member
Reaction score
9
If you make a temporary unit group why must you delete it after you're done? The variable would still be kept track of and if you wanted to use it again, you could just overwrite it?
 

simonake

New Member
Reaction score
72
If you don't plan to use a group anymore, destroy it. If you want to create a new group with the same variable (wich is what GUI does), you must destroy it or the game will remember it till end of game, causing lot of lag. If you want to use it sereval time and later in the game, don't destroy it.
 

elmstfreddie

The Finglonger
Reaction score
203
Keyword: Temporarey.
If you were to re-use the variable then you wouldn't need to delete it.

Normally though, people make groups without realising. Using functions like "units within x distance"... "every unit under these conditions"... kind of thinsg. It creates groups that never are remoevd. That's why you set a variable to it so it CAN be removed.

Ehm, so if you wanted to the same 12 units all game you'd never delete that variable.

I'm not really sure if that was your question though?
If you're asking where the data goes that the variable previously had when it's rewritten, then I presume it's removed, but you can't presume anything with WE.. :p
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Globals can be overwrited. Actually destroy group is unsafe. The safest method is recycle it by using Group Clear
 

crabbb622

New Member
Reaction score
9
Ok so let's say i pick up some units and put it into tempGroup. So then i can say Pick up every unit in tempGroup and do crap, which will not cause a memory leak (allegedly...). Word on the street is that you use custom script to burn that variable to the ground and never see it again. And when you want another temporary group, you store the new units into the group.

What I'm asking is that is it necessary to manually remove the variable, since overwriting it would naturally destroy it. Or rather, doesn't tempGroup always point to the same exact spot in memory throughout the game?

Edit: And yea, all i need is to verify kingkingyyk3's technique.
 

Tom Jones

N/A
Reaction score
437
Ok so let's say i pick up some units and put it into tempGroup. So then i can say Pick up every unit in tempGroup and do crap, which will not cause a memory leak (allegedly...). Word on the street is that you use custom script to burn that variable to the ground and never see it again. And when you want another temporary group, you store the new units into the group.

What I'm asking is that is it necessary to manually remove the variable, since overwriting it would naturally destroy it. Or rather, doesn't tempGroup always point to the same exact spot in memory throughout the game?

Edit: And yea, all i need is to verify kingkingyyk3's technique.
To understand leaks we'll first have to clarify some stuff:

The variable types that leak are different from the ones that don't. Variable types that don't leak uses their space in the memory to hold a direct value, whereas variable types that leaks uses their space in the memory to point to an object in the memory.

Overwriting a variable of a type that points somewhere will only result in a new pointer. The object in the memory that the variable used to point to is still allocated in the memory, and since we overwritten the variable with a new pointer we have no chance of destroying said object. We've created a leak.

That's why it's necassary to clean objects from the memory before assigning a new pointer to the variable.

As kingkingyyk3 said you can also deal with this by using a static object. Because we never destroy the object or assign a new pointer to the variable, we'll reference the same object throughout the entire game. However DestroyGroup(...) is plenty safe.
 

crabbb622

New Member
Reaction score
9
Overwriting a variable of a type that points somewhere will only result in a new pointer. The object in the memory that the variable used to point to is still allocated in the memory, and since we overwritten the variable with a new pointer we have no chance of destroying said object. We've created a leak.

As I understood it, a certain amount of memory is given to a pre-specified variable and that block of memory would hold a changable value. Are you saying that every time a variable is stored, it goes to a different place (or that changing the value of the variable actually means pointing to a different loacation in memory)?
 

Tom Jones

N/A
Reaction score
437
As I understood it, a certain amount of memory is given to a pre-specified variable* and that block of memory would hold a changable value. Are you saying that every time a variable is stored, it goes to a different place (or that changing the value of the variable actually means pointing to a different loacation in memory)?**
*Correct.
**Correct, but only for variable types that leaks.
 

crabbb622

New Member
Reaction score
9
So would this work:

Trigger:
  • End Copy Copy
    • Events
    • Conditions
    • Actions
      • Set tempGroup = (Units in (Playable map area))
      • Unit - Explode (Random unit from tempGroup)
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Move To (Random point in (Playable map area))


And I wouldn't even have to clean that up to reuse tempGroup for something else?
 

crabbb622

New Member
Reaction score
9
Sorry, what i meant to ask is: Isn't removing it from memory unnecessary because if you're just going to leave the group untouched, but still existing, it won't cause more memory to be taken up.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
Because in the future (multiplayer game) it will generate lots of lag if you do not clean up your leaks.

Read this if you want to learn more about Memory Leaks and Custom Script Guide;

http://www.thehelper.net/forums/showthread.php?t=27219&highlight=leaks

This is just not true, a lot of people have become leak nazi's but they overstate things a bit, you can get over 500K leaks with no visable lag, you wqill notice the leaks when the game is over and it takes forever to close the map, but it is only certain types of leaks that will cause lag, and even then not always.

To put this simple if your map is going to be played and won in under 20 to 25 minutes don't bother removeing leaks, you wont notice them. 25 to 30 minutes just remove the constant leaks, any thing more then 35 then you will want to remove as many as you can.
 

SpaceBar

New Member
Reaction score
16
This is just not true, a lot of people have become leak nazi's but they overstate things a bit, you can get over 500K leaks with no visable lag, you wqill notice the leaks when the game is over and it takes forever to close the map, but it is only certain types of leaks that will cause lag, and even then not always.

To put this simple if your map is going to be played and won in under 20 to 25 minutes don't bother removeing leaks, you wont notice them. 25 to 30 minutes just remove the constant leaks, any thing more then 35 then you will want to remove as many as you can.

True, but in most cases, it's always best to remove most if not all the leaks anyway
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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