Question

There's a useful warning in the performance section on string interning on MSDN:

the memory allocated for interned String objects is not likely be released until the common language runtime (CLR) terminates.

But: when does the CLR terminate?

Was it helpful?

Solution

The simple answer is: the CLR terminates when the host (process) terminates.

Also, there is a default AppDomain (that is not accessible). This AppDomain would continue to exist even if your AppDomain is unloaded. This is what I think Tigran was referring to as System.

OTHER TIPS

There is a good Code Project article that goes into some details about the life-cycle including CLR termination.

http://www.codeproject.com/Articles/16164/Managed-Application-Shutdown

That article in turn is inspired by: http://blogs.msdn.com/b/cbrumme/archive/2003/08/20/51504.aspx

Most probababbly documentation refers to fact that CLR "thread" associated with your process will be terminated, as documentation correctly says, that inter string:

The common language runtime conserves string storage by maintaining a table, called the intern pool, that contains a single reference to each unique literal string declared or created programmatically in your program. Consequently, an instance of a literal string with a particular value only exists once in the system.

and not in your application. In fact reading further it says:

CLR's reference to the interned String object can persist after your application, or even your application domain, terminates...

So basically the storage where these data is placed goes out of your process address space, and so remains in the system event after your process termination.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top