简体   繁体   English

分析为什么在对应用程序进行性能分析时会在内存中保留更多的字符串对象

[英]Analyzing why more number of string objects are held up in the memory while profiling my application

I have been profiling my application for a high CPU issue(CPU clocking around 80% during load test). 我一直在分析我的应用程序以解决高CPU问题(负载测试期间CPU时钟大约80%)。 One of the feed back that we got from the MS Support team is that the Full GC has been running every 2seconds and that is CPU intensive and they mentioned there are many string objects being created. 我们从MS支持团队获得的反馈之一是Full GC每2秒运行一次,并且占用大量CPU,他们提到要创建许多字符串对象。 Hence, I have been profiling the application using ANTS profiler and I see the html markup that we are dynamically rendering in a custom web control are being held up in the memory(shown by ANTS profiler). 因此,我一直在使用ANTS Profiler对应用程序进行性能分析,并且看到在内存中保留了我们在自定义Web控件中动态呈现的html标记(由ANTS profiler显示)。 Even if the string that we dynamically binding to button onclick event is being held onto the memory. 即使我们动态绑定到按钮onclick事件的字符串被保留在内存中。

Eg: 例如:

protected void Page_Load(object sender, EventArgs e)
{
    Button1.Attributes.Add("OnClick", "return ValidateTheWorksheet('Default');");
}

In the above code, ANTS profiler shows String "return ValidateTheWorksheet('Default');" 在上面的代码中,ANTS探查器显示字符串"return ValidateTheWorksheet('Default');" is held up onto the memory even after the page is completely rendered. 即使页面完全渲染后,它仍保留在内存中。

ANTS profiler support says that every memory snapshot does a full GC collection. ANTS探查器支持说,每个内存快照都执行完整的GC收集。 Then Why is that string coming up in the memory? 那为什么这个字符串会出现在内存中呢?

Any advise would be helpful... 任何建议都会有所帮助...

Thanks 谢谢

The issue has been resolved. 该问题已解决。 It was found to be one of the dependent team's reusable code, where they had a linq query and within the linq query they were doing string comparison using ToUpper and Trim function. 发现这是相关团队的可重用代码之一,他们在其中使用linq查询,并在linq查询中使用ToUpper和Trim函数进行字符串比较。

As, it will be in a loop for the entire list, the piece of the logic was CPU expensive. 由于整个列表都将处于循环中,因此逻辑部分非常昂贵。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM