开发者

Is const string eligible for garbage collection?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜