PowerBuilder application execution error (R0108) Not enough memory to execute the operation

Symptom

PowerBuilder application execution error (R0108)

Application Terminated
Error: Not enough memory to execute the operation at line 3 of ......

Environment

PowerBuilder

Reproducing the Issue

Using the Fill ( chars, n ) function in the following code produces the error. The 'n' parameter is a long value and the length of the string returned.

String ls_string
a = Fill("y",250000000)

The actual value shown above, 250000000, will vary.

To reproduce, if the long parameter above does not fail, increase the value and watch memory usage in task manager.  The memory will increase until it fails.

Error can also occur with other string functions. 

Cause

The maximum size string you can create is determined by the memory that is available to allocate in contiguous blocks.

The long parameter value is less than the documented maximum Unicode string length of 1073741823.

Solution

If this error occurs, reduce the size of the string until it no longer fails.