MFC 应用程序如何提交虚拟内存?
我正在开发一个 MFC 应用程序,它似乎会自动分配约 160MB 的虚拟内存。该应用程序通常以 10-14MB 的内存使用量运行,因此这一级别的提交内存似乎过多。此外,代码中没有任何地方调用 VirtualAlloc... 通讯与通讯ATL 也正在被使用。
在到达 __tmainCRTStartup 中的断点之前,内存显示进程启动的实例已提交。
如何保留/提交该内存?
提前致谢!
I am working on an MFC app that seems to be automagically committing to ~160MB of virtual memory. The app typically runs at 10-14MB of memory usage so this level of committed memory seems excessive. Additionally there is no where in the code where VirtualAlloc is called...
COM & ATL are also being used.
The memory shows as committed the instance the process launches, before a breakpoint in __tmainCRTStartup can be reached.
How can this memory be reserved/committed?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一的原因可能是您使用的 DLL。我在许多项目中使用过 MFC 7.0 和 9.0,并且可以告诉您它们不会占用这么多内存。
The only reason can be a DLL you use. I've used MFC 7.0 and 9.0 for many projects and can tell you that they don't commit this lot of memory.
事实证明,有一些“遗留”代码使用自定义对象的静态数组,分配了大约 1000 个额外元素,因此将其更改为使用 std::vector 完全缓解了这个问题......
Turned out there was some "legacy" code using a static array of custom objects that allocated around 1000 extra elements, so changing this to use a std::vector alleviated this issue completely...