Skip to main content

Long Strings

Long Strings

Caché supports two maximum string length options:

  • The traditional maximum string length of 32,767 characters.

  • Long Strings maximum string length of 3,641,144 characters.

Long strings are enabled by default. If long strings are enabled, the maximum length of a string is 3,641,144 characters. If long strings are disabled, the maximum length of a string is 32,767 characters.

Attempting to exceed the current maximum string length results in a <MAXSTRING> error.

You can return the current system-wide maximum string length by invoking the MaxLocalLength()Opens in a new tab method, as follows:

   WRITE $SYSTEM.SYS.MaxLocalLength()

You can use any of the following operations to enable or disable long strings system-wide:

  • In the Management Portal, select System, Configuration, Memory and Startup. On the System Memory and Startup Settings page, select the Enable Long Strings check box.

  • In the Caché parameter file (CPF file), specify the value of the EnableLongStrings parameter, as described in the EnableLongStrings section of the Caché Parameter File Reference.

  • In the Config.MiscellaneousOpens in a new tab class properties, specify an EnableLongStringsOpens in a new tab boolean value. This modifies the corresponding CPF file parameter. For example:

      ZNSPACE "%SYS"
      SET getstat=##class(Config.Miscellaneous).Get(.Properties)
        IF getstat '= 1 {WRITE "Get config property error",! QUIT}
      SET Properties("EnableLongStrings")=0
      SET modstat=##class(Config.Miscellaneous).Modify(.Properties)
        IF modstat '= 1 {WRITE "Modify config property error",! QUIT}
    

When a process actually uses a long string, the memory for the string comes from the operating system’s malloc() buffer, not from the partition memory space for the process. Thus the memory allocated for actual long string values is not subject to the limit set by the maximum memory per process (Maximum per Process Memory (KB)) parameter and does not affect the $STORAGE value for the process.

FeedbackOpens in a new tab