I did some experimenting on this and it seems a basic 32-Bit PB app can allocate about 1,376,780,254 bytes of RAM. But not all at once. The only way I could come even close to that number was in incremental steps by allocating increasingly smaller blobs. The basic code block to create a single block looks like this. I used a new blob variable for each iteration.
ls_spaces = space( ll_spaces )
lblb_test = Blob(ls_spaces, EncodingUTF8!)
ls_spaces = ''
I used UTF8 because in case of spaces this will result in a blob exactly the size of ll_spaces in bytes. ANSI would probably work the same. I started out with one below the supposed maximum supported by Space (2147483646) but that would always error out with "Not enough memory to execute..."
Then I halved the amount with each step.
1073741823: "Not enough memory to execute..."
536870911: "Not enough memory to execute..."
268435455: NO error message so the string was created but it would just silently crash at the line creating the blob from the string.
134217727: This finally worked. But only three times, then I had to go down by half again. In the end it took the following to approach the apparent memory limit:
3x134217727
9x67108863
8x33554431
1x16777215
13x8388607
1x4194303
3x1048575
=~1.3GB RAM. After each allocation crashed I went down by half. No idea why at one point the 16MB allocation failed while 13 8MB blobs could still be created without issue. I mean there's obviously overhead from creating the string variable but it shouldn't be that much? I dunno.
I also tried compiling to 64bit and 64Bit PB Apps handle memory allocation a lot better but it STILL won't allow the supposed maximum for the Space function. The actual maximum seems to be 1053140931, because at 1053140932 it starts to give you the "Not enough memory to execute..." RTE.
In 64bit, the actually available RAM seems to be the limit, I could create 16 ~1GB blobs with no issues. Doing any concatenation etc. with strings this large still just silently crashes the app, though.
My results for the most part are similar to yours but do differ a bit, primarily on the 64 bit side of things, where I didn't receive a memory error at all and only crashed silently if I went beyond 1,053,140,000 bytes (I didn't test out as far as you did to the last byte) when executing string assignments. If I did go beyond that size then I would get the silent crash. I only experienced the "Not enough memory..." error if the app runs out of memory, which it never did under a 64 bit EXE (I'll elaborate in my reply).
As for "No idea why at one point the 16MB allocation...", not sure whether it would make a difference if you used SetNull(ls_spaces) and GarbageCollect(). It wouldn't surprise me if it didn't make a difference as it just feels like in the 32 bit environment memory management could be much improved.
Regards...Mark
Yes, I deployed both 32bit/64bit exes, running from the IDE crashes much earlier. It also makes a difference if the IDE is still running when starting a deployed app but not as much as running from IDE directly.