by Michael S. Kaplan, published on 2011/07/11 07:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2011/07/11/10183229.aspx
The message that came from Josh was an interesting one:
I’m investigating unexpectedly high memory usage in a feature I wrote, and I tracked it down to the fact that getting the DisplayName property of a CultureInfo object (InvariantCulture in this case) seems to trigger allocation of literally thousands of strings, which are not GC’d as far as I can tell. Is this a known issue? I can provide some example callstacks (at the point the allocations occurred) if it helps.
People have a tendency to look at the way memory gets used in the .NET Framework, so this particular allocation comes up from time to time.
Basically, it is for filling in locale data in the hash nodes that the .NET BCL uses to store its list of locales and the data in it.
The list is fairly static per machine (even when custom locales are installed, this is not a very common occurrence), and as data that is unlikely to change often but which may be requested at some point if it was ever requested. If it never is then it will page out eventually, but freeing it isn't necessarily a reasonable thing to do....
Now I'm not gong to unilaterally defend the design here, since I'm sure any compotent person reading this blog can question some of the actual allocations here, in some cases.
But in the end, I know that the people who have a full time job keeping that memory size down are the ones in the best position to fight those battles, so even if I am startled I shouldn't be too surprised or shocked. Therefore I am going to set that argument aside and assume that the people who did it had their reasons and that they are reasonable.
Perhaps, as can be the case in this Blog, it might make more sense to attack a different notion.
You may remember when I wrote Having neither army nor navy, Invariant is apparently just a dialect.
Now perhaps requesting the invariant culture's display name -- Invariant Language (Invariant Country) -- may seem important.
But if the locale is not being used for anything else than it probably isn't worth it.
And that is from me, speaking as the person who took Microsoft down the road of filling in all this data -- for the locake/culture that doesn't even exist, in this world where everything varies....
go to newer or older post, or back to index or month or day