Skip to main content

Explain how string interning works in .NET and when it becomes harmful.

Expert C#
Quick Answer String interning stores one shared instance of each unique string literal in a process-wide pool. Two equal string literals share the same object in memory. This saves memory for repeated strings. The danger: interning user input or dynamic strings fills the pool permanently, causing memory growth that the GC cannot reclaim.

Answer

Intern pool stores unique string instances for process lifetime.

Benefits: deduplication of literals. Harmful: unbounded memory use if interning user input.

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