0 votes

I have a dialog box (just a RichTextLabel) that I would like to output continuous bbcode text to. As another line of text comes in, the log starts a newline /n and adds the next line.

It works fine. I continuously load the separate strings into an array. Whenever a new string item is added to the array, I concatenate each string into one string (we will call it log) and update the label.

I am worried when I have a few dozen or a few hundred lines of text, if that final concatenated string (log) will be able to store all the information. I am not sure the string size limitation on a 64bit device, but regardless of the max, I know it is there.

The only solution I can imagine is to chop the log at size x by popping off the earliest array entries one by one.

Thanks for the additional insight/ideas.

asked Mar 27, 2019 in Engine by CalmTurtle (142 points)

1 Answer

+1 vote
Best answer

The limit is 32-Bit at the least. That would be 2GB when using signed ints.
That would be 25 million lines if each line has 80 characters.
...and I'm wondering if the length limit isn't actually 64bit....

Your problem when working with that big strings will be performance, not length.
I'd say: Yes, crop the string at a much lower limit. You can also use somestring.find("\n", (some offset)) to cut whole lines. Then use somestring.right(offset+1) to get the new shortened part. You'll have to reassign the string to the rich text control.

To make sure it works I'd debug/test with a much lower limit (i.e. 300 characters or so).
Then I'd also implement a threshold. So i.e. when the string exceeds 3MB length, cut back to 2MB length. (depending on how much text you want to allow the user to scroll back.)

Probably the question of how much text you want to retain will more depend on how much the user will comfortably be able to manage with keyboard or scrollbar than limitations on memory/string length or performance.

answered Mar 28, 2019 by wombatstampede (3,193 points)
selected Mar 28, 2019 by CalmTurtle

Thank you for the answer and the scientific explanation. Took me a minute to wrap my head around a 2GB string but I got it. I will experiment with the performance side and see how it goes.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.