Skip to main content

Explain String Interning and its risks.

Expert .NET Core
Quick Answer String interning stores one shared instance per unique string literal. string.Intern() can intern any string. Interned strings live in a process-wide pool and are never GC'd. Risk: interning dynamic strings (user input, random data) fills the intern pool permanently, causing memory growth that GC can't reclaim.

Answer

Intern pool stores unique literals for lifetime of the process. Reduces duplication but increases memory pressure. Interning user input is dangerous due to unbounded growth.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice