短期高 VM 内存使用率的影响 (Windows)

发布于 2024-08-26 02:18:38 字数 697 浏览 6 评论 0原文

在我正在编写的应用程序中,我使用了很多内存容器(C++ std 容器,但我认为这不相关)。

在我的应用程序的一项“任务”期间,在大量使用的边缘情况下,私有字节内存使用量达到 1GB。

作为一点背景信息,此任务是一个用户启动的任务,涉及 100,000 个文件。用户很可能会启动此操作,然后让机器继续运行。

(不,我不会做任何愚蠢的事情,比如将文件加载到内存中 - 这个足迹是与正在进行的任务相关的所有元数据)。

对于大多数用户来说,此任务期间的内存使用量可以忽略不计 - 只有 1% 的用户想要执行 500,000 件“事情”而不是 5000 件“事情”。

我正要开始一个过程,以某种方式将许多内存中的东西移动到磁盘,例如临时文件、嵌入式数据库。

但后来我想 - “等一下。所有这些解决方案本质上都是将内存缓存到磁盘。这不是虚拟内存的用途吗?”。

我对保留这些数据不感兴趣 - 这纯粹是任务运行时我需要访问的临时/临时内容。

所以我的问题是,我应该做什么?

我不想对那 1% 进行重大重构,但我想知道运行具有如此高内存占用的应用程序的影响。

我是否正确地说我可能无法比 Windows VM 管理器做得更好?

在什么情况下这会变得有害?好吧,是的,如果我用完了所有的实际内存,那么重新加载页面就会很麻烦。但如果是嵌入式数据库的话,我难道不会有这样的情况吗?

干杯,

约翰

In the app I'm writing, I use a lot of in memory containers (C++ std containers but I don't think that's relevant).

During one "task" of my app, in a heavy usage edge-case the private bytes memory usage hits 1GB.

Just as a bit of context, this task is a user initiated task involving 100,000s files. It's likely that the user will kick this off and then leave the machine running.

(And no I don't do anything dumb like load files into memory - this footprint is all metadata related to the task in progress).

For most users the memory usage during this task is negligable - it's just the 1% of users who want to do 500,000 "things" insted of 5000 "things".

I was about to embark on a process to move a lot of this in-memory stuff to disk somehow, e.g. scratch file, embedded DB.

But then I thought - "hang on a minute. All of these solutions are essentially caching memory to disk. Isn't that what Virtual Memory is for?".

I'm not interested in persisting this data - it's purely scratch/temporary stuff I need access to while the task is running.

So my question is, what should I do?

I don't want to do a major refactor for that 1%, but I want to know the impact of running an app with that high a memory footprint.

Am I right in saying that I probably wouldn't be able to do much better than the Windows VM manager anyway?

Under what conditions does this become harmful? OK so yes, if I used up all the real memory then it'd be thrashing to reload pages. But wouldn't I have that anyway in the case if e.g. an embedded database?

Cheers,

John

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

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

发布评论

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

评论(1

吃→可爱长大的 2024-09-02 02:18:38

是的,内存管理器会为您完成这项工作。但并非没有副作用,它会从 RAM 中逐出其他进程已映射的页面并将其提供给您。其他进程会因此而变慢,当它们访问此类换出的页面时,它们会遇到页面错误。

这里的平衡行为是你的应用程序是否“重要”到足以证明其他进程不被忽视。通常,在工作站上是“是”,在服务器上是响亮的“否”。

Yes, the memory manager will do the job for you. Not without side-effects though, it is going to evict pages from RAM that other processes have mapped and give them to you. Those other processes are going to get slowed down by this, they'll be hit with a page fault when they access such a swapped-out page.

The balancing act here is whether your app is "important" enough to justify those other processes from getting short shrift. Usually that's Yes on a work station, a resounding No on a server.

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