Let's talk about memory leaks

crabbb622

New Member
Reaction score
9
Code:
        Set Temp_Group = (Units in (Playable map area))
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Unit - Kill (Picked unit)
        Custom script:   call DestroyGroup (udg_Temp_Group)

I've always been skeptical of this last line (destroying the variable), although you guys are experienced i guess so it must be right.
But...
Why wouldn't the variable clean itself up on being overwritten. I mean, I would understand if it was a different variable being used each time, but aren't we using the same block of memory each time here?

Can someone explain on a low-level perspective of why this is? It's not in the tutorial because I suppose you don't really need to know, but it's really bugging me.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
The variable is just a pointer to where the data is stored. Thus, if you overwrite the pointer, you don't get rid of the actual data. So it stacks up in memory. A leak. To get rid of the actual data, that function is what you use.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I'm pretty sure it actually creates a new group in the memory each time.
So everytime you run it without the removal, it leaks a group.
 

Azlier

Old World Ghost
Reaction score
461
The variable is merely pointing to an object. If you reset the variable, you lose the object in memory. You have to destroy the object before you lose it by resetting the variable.

EDIT: How did two people post within 5 seconds?
 
Reaction score
341

Azlier

Old World Ghost
Reaction score
461
Then what are we supposed to say? Doohickey? Thingamabob?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Well that's just hick :p .

Think back to when you were (Completely) new though;
You probably got confused by things like that ;) .
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Pointer? Name? Label? Title? Reference? Id?
The point is that it isn't the actual data, but merely a name for it. If all you do is make the name reference something new, you haven't gotten rid of the initial data, and since there is no way to name it now, it's gone forever, lost in the depths of RAM....
 

Azlier

Old World Ghost
Reaction score
461
There is only one way to clean objects you never reference by pointing to them via variable. It is a truly evil hack. Something much more mysterious than this.
 

Pyroflame

New Member
Reaction score
4
Saying pointer is fine... "Pointer" "Point" "Pointing to something" how could you go wrong with using that word. Ghan_04 had the best defination.
 

crabbb622

New Member
Reaction score
9
guys...low-level doesn't mean five year old. it means computer-level concepts, like assembly programming, if you've ever heard of that. lawl.

anyway, so from what i understand the computer allocates memory every time you set a value to a variable at ANY time and when you overwrite it, it never tells itself that that memory is free now?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
Whenever you create an object of some type, it allocates the memory. CreateGroup(), etc. all do this. But once you shift the pointer away from that allocated memory space without clearing it and go around creating more allocated spaces, you leak.
 

Azlier

Old World Ghost
Reaction score
461
Jass doesn't have an automagic garbage collector.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
> Jass doesn't have an automagic garbage collector.

Yet. :p
We can always hope for SC2.... Even though I have no idea if they will use JASS there.
 

crabbb622

New Member
Reaction score
9
> Jass doesn't have an automagic garbage collector.

Yet. :p
We can always hope for SC2.... Even though I have no idea if they will use JASS there.

haha, i have been wondering what kind of editor SC2 will have. waiting for it :O

Anyways, thanks guys, i understand it now
I won't have to stay up all night thinking about it
 
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

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top