Page 1 of 1
SC question: max length of string?
Posted: 08 Sep 2015 08:45
by autocart
Hi all, Hi Don,
Simple question, but I could not find the answer neither in the help file nor here with the search function in the forum:
In XY what is the max length allowed for a string (especially in scripting but if it differs in other places it would also be good to know).
E.g. I wonder about it when retrieving / passing a string of many file paths. How many file paths can I max include (in average worst case)? What is the limit?
Thx and regards
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:04
by admin
2 GB bytes (that's 1 GB characters) in theory. But a number of factors will reduce it somewhat in reality.
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:18
by highend
I can write 128MB of text data (the string "a") that is hold in a variable, but XY passes already
on 256 MB (see screenshot).
x64 OS, 16GB RAM, 12GB available...
Unbenannt.png
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:25
by admin
I think the 1 GB characters is only valid if this is the only string around.

But XY's source code has a couple of other strings busy while you are scripting...
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:37
by highend
No problem, that's still about half a million 255 char long paths...
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:43
by autocart
highend wrote:I can write 128MB of text data (the string "a") that is hold in a variable, but XY passes already
on 256 MB (see screenshot).
x64 OS, 16GB RAM, 12GB available...
Unbenannt.png
Sorry, highend, I do not understand this.
1) Why do you say "XY passes
already" when 256 MB is
more than 128 MB?
2) What does the screenshot say regarding the length of the string at the time of the error?
I cannot see it. It says "Not enough string memory" ("Nicht genĂ¼gend Zeichenfolgenspeicher") but I cannot see how much string memory used by the string causing the error. Or do I overlook something? (Sorry for being doo dumb.)
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:48
by highend
1. Replace pass with "pass out", "struggle" "can't keep up with", anything like that
2. I wanted to show Don a screenshot of the message. I didn't say that it would show the length of the variable / data
Re: SC question: max length of string?
Posted: 08 Sep 2015 09:49
by autocart
Thinking of which...
Does XY (scripting that is) automatically free memory from string variables after they are not used anymore?
-) If yes what determines whether is is still used or not (and therefore the memory available again).
-) If no, can I do so manually and if so then how?
Re: SC question: max length of string?
Posted: 08 Sep 2015 10:01
by highend
It frees the memory when you set it's content to empty.
Code: Select all
$a = <<<>>>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
>>>;
$b = strrepeat($a, 1280000); // 1000 = 1 MB
$b = "";
wait 5000;
Use a task manager to look at the memory that XY takes (first 5 seconds).
Re: SC question: max length of string?
Posted: 08 Sep 2015 11:43
by autocart
Thanks for the thoughts about the memory and freeing of it, highend.
highend wrote:1. Replace pass with "pass out", "struggle" "can't keep up with", anything like that
Yes, I thought so, but is 128 MB in
highend wrote:I can write 128MB of text data (the string "a") that is hold in a variable, but XY passes already
on 256 MB
not a mistake? Why would XY "already" pass out on 256 MB vs. 128 MB text data storeable? If the 128 are correct then it would not reach beyond 128 and never reach 256.
I don't get it. Did I misunderstand something?
highend wrote:2. I wanted to show Don a screenshot of the message. I didn't say that it would show the length of the variable / data
Ah, ok.
Re: SC question: max length of string?
Posted: 08 Sep 2015 11:47
by highend
Eh?
128 MB of text in a variable = working on my system
256 MB = XY spits out the error message
Anything in between = Not tested (and it doesn't matter for me because it isn't a fixed value (as Don explained))
Re: SC question: max length of string?
Posted: 08 Sep 2015 12:27
by autocart
Ah, ok, now I got it. Thx again.