VS 2017 Performance Profiler与任务管理器 [英] VS 2017 Performance Profiler vs. Task Manager

查看:447
本文介绍了VS 2017 Performance Profiler与任务管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi


我正在使用VS 2017查看我的记忆 - 我有一个异地客户在Windows窗体应用程序以
a开放几个小时后出现OutOfMemoryException错误。  


I这里不能包含图像,所以希望我能正确解释。   我的快照显示我使用的是9.6 MB的内存和141,000个对象。 当我查看
相同的应用时 通过任务管理器,它说它使用56.3 MB。  


Can有人解释为什么两个工具之间存在如此大的差异?


谢谢,Deb

解决方案

嗨Deb,


>>我正在使用VS 2017查看我的内存 - 我有一位离职后客户在离开后遇到OutOfMemoryException错误Windows窗体应用程序打开几个小时。  



你要么得到了某处内存泄漏,或手柄泄漏。两者都会给你Out of Memory错误。


你可以通过打开TaskManager来查看是否有手柄泄漏,转到View,Select Columns ...,然后打开Handles 。开始您的过程,让它运行几次迭代。记下你得到的数字。然后在几个小时后回来比较数字。
如果句柄数字相当高,你就不会处理一个比你应该的对象。


当尝试在Windows中自己绘图时,这个错误经常发生表单应用程序不知道他们必须处理他们创建的每个GDI对象,通常是钢笔和画笔。他们最终在每次调用
Paint事件时创建一个新的Pen或Brush,从不处理以前的事件,最终他们得到Out Of Memory错误。



>>有人可以解释为什么这两个工具之间有这么大的差异吗?



任务管理器显示工作集,即您使用的RAM量。探查器显示专用字节,即用于未共享的存储的虚拟内存量。


并且在调试时不检查进程内存。从调试器中运行该过程并检查。因为调试visual studio时会为你运行托管进程YourProcess.vshost.exe。这可能会引起混淆。我在控制台(用完视觉工作室)打印输出
进行了测试,结果非常好。而且这两个工具可能不会彼此同步。


这两个工具之间可能存在一些其他差异,但上面就是我所知道的。


希望有所帮助。


 


致以最好的问候,


Fletcher







Hi

I'm using VS 2017 to review my memory - I have an offsite customer who is experiencing OutOfMemoryException errors after leaving the Windows form application open for a few hours.  

I cannot include an image here, so hoping I can explain properly.    My snapshot shows that I'm using 9.6 MB of memory and 141,000 objects.  When I view the same app  via Task Manager, it says it is using 56.3 MB.  

Can somebody explain why such a large difference between the 2 tools?

Thanks, Deb

解决方案

Hi Deb,

>>I'm using VS 2017 to review my memory - I have an offsite customer who is experiencing OutOfMemoryException errors after leaving the Windows form application open for a few hours.  

You've either got a memory leak somewhere, or a handle leak. Both will give you the Out Of Memory error.

You can see if you've got a handle leak by opening TaskManager, go to View, Select Columns..., and turn on Handles. Start your process and let it run through a few iterations. Jot down the numbers you get. Then come back in a few hours and compare the numbers. If the handles numbers are considerably higher, you're not Disposing an object than you should be.

This error happens quite frequently when try to do their own drawing in Windows Forms app without knowing that they have to Dispose every GDI object they create, commonly Pens and Brushes. They end up creating a new Pen or Brush on every call of their Paint event, never disposing the previous ones, and eventually they get an Out Of Memory error.

>>Can somebody explain why such a large difference between the 2 tools?

Task Manager shows working set, the amount of RAM you use. The profiler shows private bytes, the amount of virtual memory you use for storage that isn't shared.

and don't check the process memory while debugging. Run the process out of the debugger and check. Because when debugging visual studio will run hosting process for you YourProcess.vshost.exe. That can cause confusion. I tested this with printing the output in console (running out of visual studio) and that worked perfectly. And also the two tools may not sync with each other.

There probably some other differences between the two tools but above is all I know.

Hope it helps.

 

Best regards,

Fletcher


这篇关于VS 2017 Performance Profiler与任务管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆