"TRIGSTR_1320" ? (Advanced JASSers plz)

Cohadar

master of fugue
Reaction score
209
When I convert triggers from GUI to JASS strings I use in them
are converted to "TRIGSTR_1320" and stuff like that.

Now I know WE stores them in some internal table so he can reuse them later
My question is where can I find this table?

Also if I use strings in JASS directly, like this one:

DisplayTextToPlayer(player, x, y, "hello world")

will this create a leak?

I think it will this is a local string variable after all.

So I was thinking to use something like

globals
string msg1 = "njak"
endglobals

for all my string.

am I being a "leak-freak" here?
 

Cohadar

master of fugue
Reaction score
209
I consider myself to be a good JASSer also,
it is only that now I need advice from someone better.

Download the map and see for yourself how strings leak.

Strings are Objects, they are NOT native types like integer and real.
therefore they can leak.
 

SFilip

Gone but not forgotten
Reaction score
634
Strings...well they don't exactly leak, but...keep reading.
TRIGSTR_1320 is a location in the game's string table. Every string used in warcraft is added to this table so that you can use it again afterwards.
Using the same string twice is not a leak as it already exists in the table. But using another would require more memory allocated and warcraft usually doesn't clean this up like some other programming languages.
Now war3map.wts is just the stuff preloaded into the table, it gets copied into the RAM while the map is loading.
Either way those leaks are no big deal and there is no way to fix them anyway.

And as a side note: Task Manager is NOT a good nor precise way of monitoring leaks.
The information you can get when using it is statistical at best.
 

Cohadar

master of fugue
Reaction score
209
And as a side note: Task Manager is NOT a good nor precise way of monitoring leaks.
The information you can get when using it is statistical at best.

I know, but on a simple test map when you see war3 eat 5mb per sec
it is a damn statistical guess :rolleyes:
 

--Thanatos--

New Member
Reaction score
33
Yes. Task Manager is a program where we can see Wc3 consume memories on empty map. :rolleyes:

Strings, are the the Integer and Real's friends. Try to check out the common.j.
 

Cohadar

master of fugue
Reaction score
209
Yes. Task Manager is a program where we can see Wc3 consume memories on empty map. :rolleyes:

Strings, are the the Integer and Real's friends. Try to check out the common.j.

I am fully aware of how wc3 uses memory,
but still, dynamically created strings eat memory.

And string are NOT Integer and Real's "friens"
they never were, and they never will be.

Strings "appear" like native types because JASS makes them that
way so it would be easier to use them.
(so do Java, C# and even C++)

But Strings are Objects (with variable size)
they can be created like objects,
and in C/C++ they can also be destroyed.

Just because JASS does not have a Destroy function for them
does not make them native types.

------------------

Anyway, dynamic strings do leak
(but very small amounts of memory compared to other objects in JASS)
so it is not a big deal after all.

EDIT:
I think there is one more thing that needs to be said

I am sorry about my above comment --Thanatos--
it wasn't meant to insult you.

JASS is a very simple language and fairly intelligent person can learn it in a couple of days
but because of all the limits and other "troubled" staff,
(basically Blizzards shitty design of it)
it seems that it is more important to have a lot of experience with it
no matter how much of programming you know at the moment
so you would know where are pitfalls and how to avoid them
 
A

Aw2k6

Guest
I know, but on a simple test map when you see war3 eat 5mb per sec
it is a damn statistical guess :rolleyes:

Just to add to the conversation, 5mb per sec is completely off. It's 5kb per sec. -.- 1,000 times difference is quite a bit.
 

SFilip

Gone but not forgotten
Reaction score
634
> when you see war3 eat 5mb per sec
Doesn't mean anything really.
Task manager displays memory even if it's unallocated in the game's terms (for example: when you destroy a trigger the memory it occupied will not be available for other applications; instead, some other trigger will take it's place).
Not to mention that you can't separate the memory user allocated from the one engine itself did.

> dynamic strings
Ever had the need for this in an actual map?
I mean, in quantities high enough to actually matter?
 

SFilip

Gone but not forgotten
Reaction score
634
TRIGSTR_whatever might work slightly faster when compared to using a normal string (but only for the first time) - as I already said, the wts file is cached while the map is loading. A map that has more TRIGSTRs can get it's loading time increased. Typing a string directly doesn't cache anything until you actually use it - until the trigger where you typed it is ran.
All in all typing strings directly is not only easier for you to read, but can also be better when it comes to your map's loading time. They don't leak anymore than TRIGSTRs do and there is no difference in the amount of memory used.
Also Vexorian's Optimizer inlines all TRIGSTRs with actual strings by default.
 

SerraAvenger

Cuz I can
Reaction score
234
Strings...well they don't exactly leak, but...keep reading.
TRIGSTR_1320 is a location in the game's string table. Every string used in warcraft is added to this table so that you can use it again afterwards.
Using the same string twice is not a leak as it already exists in the table. But using another would require more memory allocated and warcraft usually doesn't clean this up like some other programming languages.
Now war3map.wts is just the stuff preloaded into the table, it gets copied into the RAM while the map is loading.
Either way those leaks are no big deal and there is no way to fix them anyway.
Here is what I know about this subject. I wouldn't bet my head on it, but afaik they are all true:


>TRIGSTR_1320 is a location in the game's string table

1.: It is a pointer pointing to the data, not a location

>Every string used in warcraft is added to this table so that you can use it again afterwards.
Using the same string twice is not a leak as it already exists in the table.

2.: Not every string used is really added to that table. It are the strings to which pointers are assigned ( mostly done by warcraft while using the graphical user interface )

>Using the same string twice is not a leak as it already exists in the table.

Depends wether you use the string the pointer points to or a string wich has the same content and cannot be distinguished from the first one. In the first case, the code won't have a leak. In the second case, it will.

>[...] more memory allocated and warcraft usually doesn't clean this up like some other programming languages.

For luck JASS doesn't have a garbage collector. Much of the code you use would no longer work, you would need pointers to everything you use including: Texttags, effects, any local things and so on, in total everything that get's no pointer pointing to it by the code handling it would be destroyed ...

>Either way those leaks are no big deal and there is no way to fix them anyway.

Clearing the memory leaks would need more memory than just letting them be xD

Greetings Serra
 

Tom Jones

N/A
Reaction score
437
Depends wether you use the string the pointer points to or a string wich has the same content and cannot be distinguished from the first one. In the first case, the code won't have a leak. In the second case, it will.

Greetings Serra
Nope, two strings containing "Bob" will have the same handle id.
 

SFilip

Gone but not forgotten
Reaction score
634
> It is a pointer
I disagree.
A general definition of a pointer in programming would be an actual address in the memory which strings, by all means, aren't. In addition two strings that are the same have the same id which is something that can never (and mustn't) happen when it comes to pointers.

> the strings to which pointers are assigned ( mostly done by warcraft while using the graphical user interface )
No, we aren't talking about the same thing.
You are talking about the wts file, a list of stuff to preload to the actual cache. Yes, it does contain some UI stuff like the map name, description etc.
But I'm talking about the cache, located in the memory while the map is being played, where all used strings are.
 

--Thanatos--

New Member
Reaction score
33
Meh.

I know Strings do leak, but.. that much? Really, it's a natural leak, and not that big.

Ok, I know that I'm wrong in the part I say "Strings are integer and real's friend".

I almost forgotten about those. -.-
 

Sim

Forum Administrator
Staff member
Reaction score
534
will this create a leak?

I think it will this is a local string variable after all.

A short conclusion would look like this:

The leak is too small to worry about, and it's not like you could fix it anyway.
 

Cohadar

master of fugue
Reaction score
209
> dynamic strings
Ever had the need for this in an actual map?
I mean, in quantities high enough to actually matter?

See that is the point exactly, I really do.

I have a big multiboard with lots of player statistics,
player revival time, and a game timer
and they constantly change (i.e. use dynamic strings)

it is currently eating 50mb per one hour game,
and it does not free that memory up afterwards :(
It's really pissing me off.
 

SFilip

Gone but not forgotten
Reaction score
634
> it is currently eating 50mb per one hour game
> and it does not free that memory up afterwards
Task Manager again?
Once again: don't trust it when it comes to memory leaks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top