Hashtables and Memory Leaks

Definitely NOT (It ruins my trigger as well, seems that location isn't exist). Anyway I have changed save location to save real(LocX and LocY) instead and it works efficiently. (I don't really care much about leak but this force me to use real :p)



This may explain the reason why.

Believe me, use GetLocationX and GetLocationY is better.


This may explain the reason why you're doing it wrong? :p

I can't believe you that using LocX and LocY is better without anything more than you saying so.
 
So TempPoint won't exist anymore if RemoveLocation is used, even if it's already saved in the hashtable?
I thought of just doing something like
Code:
call RemoveLocation(LoadLocationHandleBJ(GetHandleIdBJ(GetTriggerUnit()), udg_LocationInteger, udg_Hashtable)

Would that work?
 
> When ever I've saved points into hashtables I save them directly. Like saving (Position of (Triggering Unit)). But does that create leaks?
It's not quite a leak, as you can still reference the location and remove it afterwards. When you no longer need that location, load it from the hashtable and use RemoveLocation. Leaks are handles that are still in memory that you're not using and have lost reference to.

> I believe that's what Romek means.
Yup.

> Believe me, use GetLocationX and GetLocationY is better.
I don't believe you.

> So TempPoint won't exist anymore if RemoveLocation is used, even if it's already saved in the hashtable?
TempPoint can point to any single location. If you store that location into a hashtable, you could reference it either by loading it from the hashtable, or using TempPoint (it would be the same location, regardless). You could set TempPoint to some other location if you wanted, and still be able to reference that first location through the hashtable (though TempPoint will now be a different location). Neither of these locations would be leaks until they were no longer being used. Using RemoveLocation(udg_TempPoint) removes whatever location TempPoint is set to. However, note that handles are pointers, so that'd also make all other references to that location null (such as ones that have been saved into hashtables), so you wouldn't be able to load that same location from a hashtable after. Basically, only remove locations once you're done with them. The actual location, that is. Not necessarily the variable.

> Would that work?
Well, yes. Why would you ever want to do that though? o_O
 
> When ever I've saved points into hashtables I save them directly. Like saving (Position of (Triggering Unit)). But does that create leaks?
It's not quite a leak, as you can still reference the location and remove it afterwards. When you no longer need that location, load it from the hashtable and use RemoveLocation. Leaks are handles that are still in memory that you're not using and have lost reference to.

> So TempPoint won't exist anymore if RemoveLocation is used, even if it's already saved in the hashtable?
TempPoint can point to any single location. If you store that location into a hashtable, you could reference it either by loading it from the hashtable, or using TempPoint (it would be the same location, regardless). You could set TempPoint to some other location if you wanted, and still be able to reference that first location through the hashtable (though TempPoint will now be a different location). Neither of these locations would be leaks until they were no longer being used. Using RemoveLocation(udg_TempPoint) removes whatever location TempPoint is set to. However, note that handles are pointers, so that'd also make all other references to that location null (such as ones that have been saved into hashtables), so you wouldn't be able to load that same location from a hashtable after. Basically, only remove locations once you're done with them. The actual location, that is. Not necessarily the variable.

Doesn't that do this?
 
I believe he meant load it from the hashtable like Set TempPoint = Load 0 from Key(Triggering Unit) in Hashtable.
 
Sorry for the offtopic post, just reading this and had to quote Romek
> Believe me, use GetLocationX and GetLocationY is better.
I don't believe you.

LoL thank though. Anyway may I have your reason (Romek Reason)?
I have my own reason that real will not leak.

I believe Romek have better and there maybe sth I should learn.
 
Yes, we know reals don't leak. So you're saying, we should instead of using a point, which would save ONE value, we should use TWO reals? When points work just as well.
 
> Yes, we know reals don't leak. So you're saying, we should instead of using a point, which would save ONE value, we should use TWO reals? When points work just as well.
It's not really about using one value instead of two.

In JASS, using two reals is always preferred over a location (with a minor exception of checking terrain height). Locations in general are pretty much GUI-exclusive, because of how inferior they are compared to using coordinates directly. Coordinates can be easily manipulated mathematically (whereas locations can't), and using them gives you the flexibility of easily doing whatever you want with positions. Almost all location functions (such as polar offset) first convert to reals, then do whatever they need to do, before converting the resulting reals back into a location. Then there's also the leak to clean up. Reals are, in theory, much more efficient and flexible than locations.

However. This is GUI, not JASS. There's a lot of support for locations compared to coordinates, which makes using reals quite difficult, and will probably result in converting them to a location quite often (or result in using relatively complicated custom scripts - though if you can do that, you shouldn't even be using GUI). There can also be quite a lot of maths involved with reals, and I'm sure you all know that anything past simple arithmetic maths is a pain to do in GUI.
Besides all of that, GUI is horrible efficiency-wise anyway, and there's nothing at all you can do about that. It's pointless to go out of your way to make a small efficiency tweak when every if-condition block (amongst many other actions) you use set that back in the opposite direction again. It's not a game-breaking difference, but it's more than enough to warrant prioritizing readability and usability over efficiency. Just stick to what GUI is best at: simple, English, readable* code.

Edit: You specifically mentioned using GetLocationX and Y. You're not accomplishing anything there, as you're using both locations and reals.
 
I love how you reply Romek, Your replies are always the best.

@This topic. All Romek was saying without reading his wall of text like I just did, is that GUI was made for Locations, (Not GUI, but it was made to USE locations) and JASS was used to make reals, so that way you can basically use natives, (no known source, just what I think) to efficientize it. (I'm using my word again)
 
> Yes, we know reals don't leak. So you're saying, we should instead of using a point, which would save ONE value, we should use TWO reals? When points work just as well.
It's not really about using one value instead of two.

In JASS, using two reals is always preferred over a location (with a minor exception of checking terrain height). Locations in general are pretty much GUI-exclusive, because of how inferior they are compared to using coordinates directly. Coordinates can be easily manipulated mathematically (whereas locations can't), and using them gives you the flexibility of easily doing whatever you want with positions. Almost all location functions (such as polar offset) first convert to reals, then do whatever they need to do, before converting the resulting reals back into a location. Then there's also the leak to clean up. Reals are, in theory, much more efficient and flexible than locations.

However. This is GUI, not JASS. There's a lot of support for locations compared to coordinates, which makes using reals quite difficult, and will probably result in converting them to a location quite often (or result in using relatively complicated custom scripts - though if you can do that, you shouldn't even be using GUI). There can also be quite a lot of maths involved with reals, and I'm sure you all know that anything past simple arithmetic maths is a pain to do in GUI.
Besides all of that, GUI is horrible efficiency-wise anyway, and there's nothing at all you can do about that. It's pointless to go out of your way to make a small efficiency tweak when every if-condition block (amongst many other actions) you use set that back in the opposite direction again. It's not a game-breaking difference, but it's more than enough to warrant prioritizing readability and usability over efficiency. Just stick to what GUI is best at: simple, English, readable* code.

Edit: You specifically mentioned using GetLocationX and Y. You're not accomplishing anything there, as you're using both locations and reals.

That's the main reason. I agree that using GUI is not suitable with real. Location is really better here.

Thank Romek, again. >_<
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I'm now realizing I could have cut out like 99% of this print and it would have been fine cuz I just need to see if a frame will fit over an LCD
  • Varine Varine:
    Oh well
  • Varine Varine:
    I'm not an engineer
  • Varine Varine:
    Although this filament is kind of expensive, I should probably be a bit more wary of that.
  • The Helper The Helper:
    I love the whole concept of 3D Printers and am very happy you have one so I can hear about them
  • The Helper The Helper:
  • Varine Varine:
    I have a couple of them, but I only have room for one to be set up at the moment
  • Varine Varine:
    So I picked the biggest one. When I bought it, I didn't realize that they used a lot of proprietary parts. So, I want to use these Volcano nozzles that are really cheap and easy to find instead of what they have, which are like, modified Volcano nozzles
  • Varine Varine:
    They are just a little bit longer than the regular ones. Like, we're talking .5mm or some shit. But that little bit makes the nozzle just long enough to extrude past the rest of the hardware on the extrusion system, I can't find my notes on it but I think it's like a .25mm gap from the end of the nozzle to the bed mesh sensor. Very small.
  • Varine Varine:
    So I bought a bunch of different parts to try and figure out how to make this work, and in the process changed some of the electrical components like the thermistors, but never got around to figuring out how to make the firmware account for the different hardware. Resulting in it not interpreting the voltage change to mean that the thermistor was above temperature, so it didn't shut off the heating core and it just kept pumping heat out
  • Varine Varine:
    I have most of the stuff I need to build an enclosure so I can heat the chamber for different plastics that need to have a pretty consistent temperature through the whole model, and then I can get my other ones set up too. I have a shitty Ender but that one is super easy to modify, but it's also very outdated and kind of a nightmare to work with. I think I'm going to cannibalize it for parts and just run my big one and another little one.
  • Varine Varine:
    I think I solved my problem with digitizing reels tho!
  • Varine Varine:
    Like Super 8 reels. Actual equipment to do it is like, thousands and thousands of dollars, and the cheap ones are useless, so I'm trying to build one so I can just use the same camera I use for slides and negatives. Much cheaper
  • Varine Varine:
    Anyway, it kind of works, but the take up reel is kind of tricky because you need to spin it directly to wind the tape onto it. And as it fills, you need to slow it down, and that's kind of complicated. More complicated than I wanted to try and account for, anyway.
  • Varine Varine:
    So I have the first motor that has gearing pull it from the original reel, through a set of pullies to keep some tension, and then a second motor synced with the first to guide it through the projection port so I can capture the images
  • Varine Varine:
    All that's easy enough, I just need to make sure I don't get too much force onto the film itself so I don't accidentally tear it.
  • Varine Varine:
    Then I think my solution to the take up reel is to have a kind of dancing lever on a spring in between two limit switches
  • Varine Varine:
    So, as the tape comes towards the take up reel and makes slack, that lever is pulled up by a spring to keep the tension on the film, it hits a limit switch to engage the take up reel motor at some point, and as that winds in the film, the film pushes the lever back down to a second limit switch to disengage the motor again. Slack builds up, spring pulls it back, ad infinitum
  • Varine Varine:
    Well, until the reel is empty anyway.
  • Varine Varine:
    I'm guessing it's going to be much harder than I feel like it is going to be right now, but I think it's a pretty elegant solution that doesn't rely on software to control it. The less software I need to use the better
  • Varine Varine:
    I'm just not a very good programmer, as much as I want to be I suck at it
  • The Helper The Helper:
    Programming that printer is going to be similar to programming a big machine like in a machine shop. There is good money in programming CNC machines.
  • The Helper The Helper:
    +1
  • Varine Varine:
    They are pretty similar, but this one is much less involved than a real CNC. A lot less moving parts
    +1
  • The Helper The Helper:
    Happy Monday!

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top