使用Visual Studio 2010进行内存分析 [英] Memory profiling with Visual Studio 2010

查看:135
本文介绍了使用Visual Studio 2010进行内存分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序的解决方案.一个是Windows Service项目,另一个是启动器(安装并启动Windows服务).我想将内存分析器附加到已安装的Windows服务上,以收集有关内存使用情况和对象大小的信息,以调查OutOfMemory异常.

然后,我启动启动器,启动该服务.
最后,VS 2010->分析-> Profiler->附加(连接到Windows服务).

I have a solution with two applications. One is Windows Service project, another one is launcher (installs and starts the windows service). I want to attach memory profiler to the installed windows service to collect information about memory usage and object sizes to investigate the OutOfMemory exception.

Here is the approach I used.
First I ran the "VSPerfCLREnv.cmd /samplegclife". This should init the profiling environment variables to enable memory profiling.
Then I start my launcher, which launches the service.
Finally VS 2010 -> Analyze -> Profiler -> attach (to the windows service).

但是当分析停止时,我看不到任何有关对象大小或内存使用情况的信息.
我在做错什么吗?

But when the profiling is stopped I cannot see any information about object sizes or memory usage.
Am I doing something wrong?

推荐答案

我发现了.
要将探查器附加到.net进程以收集内存数据,您应该按照以下步骤操作:

1.初始化分析环境变量:
VSPerfClrEnv/globalsamplegc
重新启动PC.

2.开始分析会话:
VSPerfCmd/start:示例"/输出:"C:\ log.vsp"/crosssession

3.将探查器附加到该过程:
VSPerfCmd/attach:[PID]

4.停止分析:
VSPerfCmd/detach
VSPerfCmd/shutdown

I found out.
To attach the profiler to .net process to collect memory data you should follow these steps:

1. Initialize the profiling environment variables:
VSPerfClrEnv /globalsamplegc
Reboot PC.

2. Start profiling session:
VSPerfCmd /start:"sample" /output:"C:\log.vsp" /crosssession

3. Attach the profiler to the process:
VSPerfCmd /attach:[PID]

4.To stop profiling:
VSPerfCmd /detach
VSPerfCmd /shutdown

有关更多信息,请参考.

For more information refer to this.

这篇关于使用Visual Studio 2010进行内存分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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