Is there a limitation for the size of a string?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
greg falda
Posts: 77
Joined: Thu Jan 15, 2015 6:51 pm

Is there a limitation for the size of a string?

Post by greg falda » Thu Jun 08, 2017 2:05 pm

Dear All

I'm planning to pass queries to SQL databases, where the queries can be potentially really long, like

Code: Select all

INSERT INTO ... VALUES ...;
where the VALUES may contain multiple rows of multiple records.

Hence my question:

Is there a limitation for the size (length) of a string in LiveCode?

Thanks in advance for your help

best
greg falda

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Is there a limitation for the size of a string?

Post by dunbarx » Thu Jun 08, 2017 3:52 pm

I think a string cannot go past the 32 bit limit, at least in 32 bit applications.

But this seems to fall short of that:

Code: Select all

on mouseUp
   put "1234567890" into temp
   repeat 26
      put temp after temp
   end repeat
   answer the length of temp --about 670,000,000 bytes
end mouseUp
If you run 27 times, LC aborts, though that length should only be about 1.3 GB. Other unknown overhead?

Craig Newman

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Is there a limitation for the size of a string?

Post by Klaus » Thu Jun 08, 2017 4:13 pm

Hi Greg,

open the "User Guide" (LC Menu -> Help) and see page 63, or search for "LiveCode Memory Limits".


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Is there a limitation for the size of a string?

Post by FourthWorld » Thu Jun 08, 2017 5:11 pm

dunbarx wrote:I think a string cannot go past the 32 bit limit, at least in 32 bit applications.

But this seems to fall short of that:

Code: Select all

on mouseUp
   put "1234567890" into temp
   repeat 26
      put temp after temp
   end repeat
   answer the length of temp --about 670,000,000 bytes
end mouseUp
If you run 27 times, LC aborts, though that length should only be about 1.3 GB. Other unknown overhead?
The 4GB of space addressable with 32-bit processes includes everything in the process. Beyond that, there are often limits with OS APIs on malloc size for certain operations. It may be that the limit you've found may be related to the latter, or a mix of both.

What are you building that needs a single string > 1.3 B? I'll bet there's a more RAM-friendly way to solve that problem.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply