I have a relatively large strings that will not change during my program run. Is it wise to mark them as const string
(in order to gain some imaginary performance benefits) ? Will the memory allocated for these string will be eventually garbage collected开发者_如何学JAVA ?
No it will not. Const strings are stored in metadata and hence are not ever collected unless the containing assembly is removed from the process. This will only happen on AppDomain unload. All uses of this string are simply references to this memory.
精彩评论