windows 什么是 sysinternals 进程资源管理器中的“虚拟大小”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3030274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:23:37  来源:igfitidea点击:

What is "Virtual Size" in sysinternals process explorer

windowsmemoryvirtual-memory

提问by robert

My application runs for few hours, There is no increase in any value ( vmsize, memory) of Task Manager. But after few hours i get out of memory errors.

我的应用程序运行了几个小时,任务管理器的任何值(vmsize、内存)都没有增加。但是几个小时后,我出现了内存不足的错误。

In sysinternals i see that "Virtual Size" is contineously increasing, and when it reach around 2 GB i start getting memory errors.

在 sysinternals 中,我看到“虚拟大小”不断增加,当它达到 2 GB 左右时,我开始出现内存错误。

So what kind of memory leak is that ? How can i demonstrate it with a code ? Is it possible to reproduce same thing with any piece of code where none of the memory value increase but only the Virtual Size in sysinternsl process explorer increase ?

那么这是一种什么样的内存泄漏呢?我如何用代码演示它?是否可以使用任何内存值都没有增加但只有 sysinternsl 进程资源管理器中的虚拟大小增加的代码来重现相同的内容?

thanks for any suggestions

感谢您的任何建议

回答by jdehaan

Virtual size is the number of pages that the process has allocated, those pages not currently in the working set (physically loaded in RAM) will be in the system's page file.

虚拟大小是进程分配的页面数,那些当前不在工作集中(物理加载在 RAM 中)的页面将在系统的页面文件中。

Typically you allocate memory that is not freed. This can be difficult to track down in the code without special tools like Rational Purify or Boundschecker for example. With sysinternals you see that there must be leak but it won't by no mean tell you where...

通常,您分配未释放的内存。如果没有像 Rational Purify 或 Boundschecker 这样的特殊工具,这可能很难在代码中追踪。使用 sysinternals,您会看到一定存在泄漏,但它绝不会告诉您在哪里......

If your software is not so big you can try to log out the "new" and "delete" and see if there are too many objects in memory by managing lists of allocated objects (making your own memory debugger so to say). There are some helpers in the windows world like the CRT memory checking utils from Microsoft. They are useful in some cases.

如果您的软件不是那么大,您可以尝试注销“新建”和“删除”,并通过管理分配的对象列表来查看内存中是否有太多对象(可以说是制作您自己的内存调试器)。Windows 世界中有一些帮助程序,例如MicrosoftCRT 内存检查实用程序。它们在某些情况下很有用。

回答by Jerry Coffin

From the sound of things, you're running out of address space. 32-bit Windows splits the address space in half, one half for the user program and one half for the system, so each gets 2 Gigabytes.

从声音上看,您的地址空间已用完。32 位 Windows 将地址空间分成两半,一半用于用户程序,一半用于系统,因此每个都有 2 GB。

The most common cause of this is fragmenting the memory space to the point that you can't find a chunk that's big enough for an allocation. Unfortunately, without knowing more about what you're doing, it's hard to guess why that might be happening though.

造成这种情况的最常见原因是将内存空间碎片化到无法找到足够大的块进行分配的程度。不幸的是,如果不了解更多关于您在做什么的信息,就很难猜测为什么会发生这种情况。

回答by Anders

According to this threadon the sysinternals forum, Virtual size corresponds to the address space of the process (I'm guessing commited and reserved pages of memory)

根据此线程上的Sysinternals论坛,虚拟大小对应于进程的地址空间(我猜COMMITED和保留的内存页)

回答by bruziuz

It seems that Virtual Size includes allocated pages with following types: MEM_MAPPED (for data views) MEM_IMAGE (for executable image views) MEM_PRIVATE (usual allocated page memory)

似乎虚拟大小包括具有以下类型的分配页面: MEM_MAPPED(用于数据视图) MEM_IMAGE(用于可执行图像视图) MEM_PRIVATE(通常分配的页面内存)

It's not the only "memory" for data, but also includes page space for *.dll-s and FileMapping mechanism.

它不是数据的唯一“内存”,还包括*.dll-s 和FileMapping 机制的页面空间。