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
Copied!
Free string allocated by write-string (consisting of 100 "Hello World"s):