Talk:String interning

message: :.NET languages, Lua and JavaScript string values are immutable and interned.
For C# (and .NET in general, for the other languages/runtimes I don't know) - as mentioned earlier in this talk - only 'string literals' are interned automatically. I think it's worth to mention. The cited MSDN article shows this.  — Preceding unsigned comment added by 37.5.252.178 (talk) 09:18, 30 June 2013 (UTC)
thread_title: Clarify

message: if you have to do a special operation to get the version in the intern pool why do strings need to be put in the intern pool as soon as they are created (couldn't they just be put in the first time an app looks for them in there?). Plugwash 22:42, 22 January 2006 (UTC)
replies: text: String costs a bit of time, but saves memory in the longer run if there are a lot of equal strings. It's a space-time tradeoff. Wouter Lievens 08:21, 22 June 2006 (UTC)
thread_title: question

message: I have been bold in updating this page, and removed a bit of content from it which I found inaccurate; notably,
:One disadvantage of the string intern pool is that since every string object must be checked against the pool at creation, there is some performance penalty even if the intern pool is never used by the application.  However, due to the possible benefits, this is generally considered acceptable in the languages in which it is implemented.
In neither Java nor the .NET Framework does the string interning occur automatically. It is up to the programmer to explicitly use the intern pool. String literals, however, are always interned anyway, so
 String.Intern("Hello World!") // C#
 "Hello World!".intern() // Java
don't make much sense. Louis 10:08, 28 January 2007 (UTC)
thread_title:  Removal of content 

message: at least three memory leaks introduced in such small code snippet, this sucks!
1. no destructor of StringTable, thus no delete of StringTable::array memory allocated at constructor
2. addString method allocates memory for array[i] variable which is neither deleted later
3. String class allocates memory for local text variable which is not freed after usage  —Preceding unsigned comment added by 80.250.171.67 (talk) 14:37, 27 July 2010 (UTC)
thread_title:  this code sucks 

message: Isn't it a kind of "string interning" for at a subset of string objects in C and C++? --RokerHRO (talk) 21:37, 19 July 2011 (UTC)
replies: text: Constant literal strings can probably be considered as automatically-interned in C and C++ since compilers will generally merge duplicates, and the string pointer may be used for comparision, but deduplication may be implementation-dependent.  However, it's of course not difficult to implement explicit string interning functionality for C or C++.  This can be implemented using a hash table or other specialized structure (new string creation/interning needs to verify if the string previously existed, but afterwards only the pointer is enough for comparison).  This is how Lisp symbols are interned in implementations written in C.  For symbols, interning makes a lot of sense, as they may be compared very frequently to other symbols using EQ (basically internally comparing their pointers or unique integer identity), in the implementation of interpreters, compilers, macros, and for dynamic function argument list processing; with most symbols interned at read/load time instead of runtime, although dynamic runtime symbol creation and interning is also possible... 76.10.128.192 (talk) 22:15, 16 June 2013 (UTC)
thread_title:  implicit (and optional) string interning for string literals in C and C++