几天后,我们的网站明显遭受内存泄漏(> 2Gb /池)。所以,我在windbg上运行了一些命令,最后找到了一些东西:有很多System.LocalDataStoreElement
。在源代码中快速搜索后(见下文),我发现了一个真正的stange类:
public class HomeController
{
public HomeController()
{
CultureInfoManager.SetCulture(MyCompany.Internal.Enumerations.Site.GbEn);
}
}
public class CultureInfoManager
{
[ThreadStaticAttribute]
private static Language _language;
public static void SetCulture(Site site)
{
if (site == Site.Undefined) return;
//strange ???
var localSlot = Thread.AllocateDataSlot();
Thread.SetData(localSlot, site.Code());
_language = site.GetLanguage();
var cultureInfo = CreateCultureInfo(site);
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
}
private static CultureInfo CreateCultureInfo(Site site)
{
if (site == Site.Undefined) site = Site.GbEn;
var languageCode = site.GetLanguage().Code();
switch (languageCode)
{
case "f2":
return new CultureInfo("fr-FR");
case "br":
return new CultureInfo("pt-BR");
case "s1":
return new CultureInfo("es-AR");
case "s2":
return new CultureInfo("es-CL");
case "e1":
return new CultureInfo("en-CA");
default:
return new CultureInfo(languageCode);
}
}
public static Language GetCurrentLanguage()
{
return _language;
}
}
所以,我的问题:
我还在MS KB here中发现了一个问题。
总之,一切似乎都在这段代码上,但我无法重现这个问题。