Delete string

Purpose: Free string memory.

 delete-string <string>

delete-string frees <string> variable previously allocated by a Golf statement.

Note that freeing memory is in most cases unnecessary as Golf will automatically do so at the end of each request. You should have a good reason for using delete-string otherwise.

Golf keeps count of <string> references for process-scoped memory (see memory-handling), and such memory will be deleted at the end of the request once reference count reaches zero.

For non-process-scoped memory, if <string> is referenced by other variables, then <string> may not be deleted. Regardless of whether the memory referenced by <string> is actually deleted or not, <string> becomes an empty string ("") after delete-string.
Examples
Allocate and free random string:
 random-string to ran_str
 ...
 delete-string ran_str

Free string allocated by write-string (consisting of 100 "Hello World"s):
 write-string ws
     start-loop repeat 100
         @Hello World
     end-loop
 end-write-string
 ...
 delete-string ws



Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.