The maximum length is actually Limits.getLimitHeapSize()
. That's because the maximum length of a string is limited to this value. You can temporarily exceed this limit across multiple objects, but doing this in a single string is not allowed; you'd get a String exception with the message startingstating that the string is too long.