• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

can string conversions cause leaks?

Status
Not open for further replies.
It makes an entry into the string table, yes.

But it isn't something you should worry about. String's memory impact is miniscule--they only take up about as many bytes as their length. Even after thousands of strings have been entered, it likely won't take up more than a few hundred kbs or a few MB's worth, which is very cheap.

String 'leaks' aren't necessarily considered 'leaks' because it is just a caching mechanism--if a string is reused, it can quickly be loaded from the table instead of being created in memory again. You shouldn't worry about it, especially not for your case. You can find out more info here in case you're interested:
http://www.hiveworkshop.com/forums/lab-715/documentation-string-type-240473/
 

Deleted member 242951

D

Deleted member 242951

Strings take up memory space, its true. But to clear that variable space, theres no way to do it. They don't cause any major problems however.
 
Level 8
Joined
Dec 10, 2006
Messages
67
What if I do it several times with several units repeatedly? I have a periodic event that converts the current order of multiple units to a string one at a time so that said string can be compared against the empty string as a means of testing a unit's potential idleness....although, now that I think about it, another possible way of doing this just popped into my head.
 
It only enters the string once. So let's say a unit uses the "smart" order, and you convert that order to a string. "smart" will be entered into the table once. After that, it just refers to that same entry--so you aren't taking up any more memory.

Let's assume a worst case scenario--your units happen to use every order in the game in existence. Even in that scenario, it still will only take up ~4.2 kb of memory total. That is practically nothing, so you shouldn't worry. :)
 
Level 8
Joined
Dec 10, 2006
Messages
67
In my editor, which is older than the hills admitedly, there are what are called advanced triggers. Among these are functions to set a unit's custom string value, a unit's custom boolean value, and a unit's custom real value in much the same way a unit's custom integer value is set. Is this no longer a thing? I use them all the time but I can see how a JASS user might not have much use for them.
 
I'm guessing you're using WEU or UMSWE. The "advanced" triggers don't necessarily correlate to JASS natives--PitzerMike would implement functions that the GUI action would call. So it is kinda like having a JASS system implemented into your map, with the convenience of having a GUI interface.

I don't remember the implementations he used. The only concerning thing is that he may have used the return bug (which would cause the map to be unopenable in current patches). But as long as your map runs fine, I guess there is no harm in using them (other people won't be able to open your map unless they have WEU though). Don't quote me on this though--this info is just coming from a distant, vague memory. I haven't used WEU since 2007 so I can't be sure.

As for your question, yes--in that case it will enter a string into the table. It should be okay. I'd only worry about string leaks if you were periodically creating a ton of strings i.e. some maps have a timer that records how long you have played and display it as a string in a multiboard. Some people include milliseconds, so you actually end up creating hundreds of strings over time. That can make a difference if your map is played long enough.

Is this no longer a thing? I use them all the time but I can see how a JASS user might not have much use for them.

Heheh, I could see some use for it. But yeah, it isn't really a thing anymore since we have indexing systems. Here is an example of one:
http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-2-0-2-a-197329/
When a unit enters the map, he is assigned a custom value that is unique. This allows you to store data representing a unit within an array (it is pretty convenient). You just slap the trigger into your map, and then those advanced triggers could be supplemented with:
  • Set String[(Custom value of <Unit>)] = "Hello world!"
  • Set Boolean[(Custom value of <Unit>)] = True
  • Set Real[(Custom value of <Unit>)] = 1.00
That is the magic of indexing systems. In fact, you can "attach" data of any type to any unit. Pretty cool, huh?
 
Level 8
Joined
Dec 10, 2006
Messages
67
I think you're right about the maps being unopenable by current users. I did some recent trigger work for a guy but he told me he was unable to load the map I uploaded. Anyway that indexing system is similar to something I'm currently implementing involving a unit's custom integer value and and an array of units. I'm rather proud of it but I imagine that I'll never be able to show it to anyone.
 
All that matters is how you feel about it. :) I often make recommendations on popular systems, but there is still merit to coding things yourself. You end up learning a lot more in the process--and even if your system might not be superior to an existing one, at least you'll know why it is inferior (which is a great learning experience).

And if your system happens to do something that the existing one doesn't--or if you approach it from a different angle, then there is no harm in showing it. :D People may criticize it and compare it to a unit indexer, but if there is some special aspect about it that you find useful, then perhaps another will find it useful as well. That's why we have The Lab. If you are just working on a system and want to know if you should release it--or if you need feedback, people will give it to you. It is a nice way to get feedback on a system without having to worry about making a submission and getting a moderator review.
 
Status
Not open for further replies.
Top