确定谁/什么在 w3wp.exe 中保留了 5.5 GB 虚拟内存

发布于 2024-07-09 10:05:48 字数 619 浏览 5 评论 0原文

在我的计算机(XP、64)上,ASP.net 工作进程 (w3wp.exe) 始终在启动时保留 5.5GB 的虚拟内存。 无论它托管的 Web 应用程序是什么(可以是任何内容,甚至是 aspx 中的空网页),都会发生这种情况。

这个大的旧虚拟内存块是在进程启动时保留的,因此这不是某种逐渐的内存“泄漏”。

用windbg进行一些窥探表明,有问题的内存是Private、Reserved和RegionUsageIsVAD,这表明它可能是有人调用VirtualAlloc的工作。 它还显示,所讨论的内存被分配/保留为 4 个大块,每个块 1GB 和几个较小的块(每个块 1/4GB)。

所以我想我需要弄清楚谁在调用 VirtualAlloc 并保留所有这些内存。 我怎么做?

在内存分配之前将调试器附加到进程是很棘手的,因为 w3wp.exe 是由 svchost.exe(即 IIS/ASP.Net 过滤器)启动的进程,并且如果我尝试自己启动它来调试它它只是关闭而没有所有这些大量的内存保留。 另外,如果我重新使用命令行参数,它们将无效(这是有道理的,因为它是由调用进程创建的管道)。

我可以在事后将 Windbg 它附加到进程中(这就是我找到有问题的内存区域的方式),但我不确定此时是否可以确定谁分配了什么。

On my machine (XP, 64) the ASP.net worker process (w3wp.exe) always launches with 5.5GB of Virtual Memory reserved. This happens regardless of the web application it's hosting (it can be anything, even an empty web page in aspx).

This big old chunk of virtual memory is reserved at the moment the process starts, so this isn't a gradual memory "leak" of some sort.

Some snooping around with windbg shows that the memory is question is Private, Reserved and RegionUsageIsVAD, which indicates it might be the work of someone calling VirtualAlloc. It also shows that the memory in question is allocated/reserved in 4 big chunks of 1GB each and a several smaller ones (1/4GB each).

So I guess I need to figure out who's calling VirtualAlloc and reserving all this memory. How do I do that?

Attaching a debugger to the process prior to the memory allocation is tricky, because w3wp.exe is a process launched by svchost.exe (that is, IIS/ASP.Net filter) and if I try to launch it myself in order to debug it it just closes down without all this profuse memory reservation. Also, the command line parameters are invalid if I resuse them (which makes sense because it's a pipe created by the calling process).

I can attach windbg it to the process after the fact (which is how I found the memory regions in question), but I'm not sure it's possible at that point to determine who allocated what.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

星軌x 2024-07-16 10:05:48

王大卫 回答了类似的问题

[...] ASP.Net 性能开发人员告诉我:

  • 预留的虚拟内存无需担心。 您可以查看
    它作为性能/缓存先决条件
    CLR 的。 以及重负载测试
    表明没有什么可担心的
    关于。
  • System.Windows.Forms - 它不是由空的 hello world ASPX 拉入的
    页。 您可以使用微软调试
    工具和“sx e ld
    system.windows.forms”来识别什么
    实际上是在运行时将其拉入。
    或者你可以通过 ildasm 找到
    依赖性。
  • mscorlib - 确保它正确地经过 GAC 和 NGen 处理。

David Wang answers this to a similar question:

[...] the ASP.Net performance developer tells me that:

  • The Reserved virtual memory is nothing to worry about. You can view
    it as performance/caching prerequisite
    of the CLR. And heavy load testing
    shows that it is nothing to worry
    about.
  • System.Windows.Forms - It's not pulled in by empty hello world ASPX
    page. You can use Microsoft Debugging
    Tools and "sx e ld
    system.windows.forms" to identify what
    is actually pulling it in at runtime.
    Or you can ildasm to find the
    dependency.
  • mscorlib - make sure it is GAC'd and NGen'd properly.
木格 2024-07-16 10:05:48

虚拟内存只是分配给进程的地址空间。 它与内存使用无关。

请参阅:

  1. 虚拟内存
  2. 突破 Windows 的限制:虚拟内存
  3. http://support.microsoft.com/kb/555223

Virtual memory is just the address space allocated to the process. It has nothing to do with memory usage.

See:

  1. Virtual Memory
  2. Pushing the Limits of Windows: Virtual Memory
  3. http://support.microsoft.com/kb/555223
在梵高的星空下 2024-07-16 10:05:48

保留内存与分配内存有很大不同。 保留内存只是分配地址空间。 它不提交任何物理页。

该地址空间可能是由 IIS 为其堆分配的。 它只会在需要时提交页面。

如果您确实想从 Windbg 启动 w3wp.exe,您可能需要使用有效的命令行参数来启动它。 您可以使用 Process Explorer 来确定当前的命令行w3wp.exe进程是。 例如,在我的服务器上,我的服务器是:

c:\windows\system32\inetsrv\w3wp.exe -a \.\pipe\iisipmeca56ca2-3a28-452a-9ad3-9e3da7b7c765 -t 20 -ap“DefaultAppPool”

我不确定其中的 UID 指定了什么,但它看起来它可能是由 W3SVC 服务(启动 w3wp.exe 的服务)动态生成的,以命名那里指定的管道。 因此,在从 Windbg 启动 w3wp 之前,您一定应该查看命令行。

Reserved memory is very different from allocated memory. Reserving memory just allocates address space. It doesn't commit any physical pages.

This address space is likely allocated by IIS for its heap. It will only commit pages when needed.

If you really want to launch w3wp.exe from windbg, you probably need to launch it with valid command-line arguments. You can use Process Explorer to determine what the command line for the current w3wp.exe process is. For instance, on my server, mine was:

c:\windows\system32\inetsrv\w3wp.exe -a \.\pipe\iisipmeca56ca2-3a28-452a-9ad3-9e3da7b7c765 -t 20 -ap "DefaultAppPool"

I'm not sure what the UID in there specifies, but it looks it's probably generated on the fly by the W3SVC service (which is what launched w3wp.exe) to name the pipe specified there. So you should definitely look at your command line before launching w3wp from windbg.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文