一旦内存使用量达到 1.5 GB,C++ 应用程序就会崩溃 [英] C++ Application crashes once it memory usage reaches 1.5 GB

查看:43
本文介绍了一旦内存使用量达到 1.5 GB,C++ 应用程序就会崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在 Windows 32 位系统上运行的 C++ 应用程序.一旦内存使用量达到 1.5 GB,它就会崩溃.我们无法理解的是为什么它会在 1.5 GB 限制而不是 2 GB 限制(虚拟地址空间和 Windows 32 位架构限制)下崩溃?

We have a C++ application running on Windows 32 bit system. It crashes once the memory usage reaches 1.5 GB. What we are unable to understand is why it's crashing at 1.5 GB limit and not at 2 GB limit (the virtual address space and windows 32 bit architecture limit)?

其他细节:-可用总内存:4GB

Other details:- Total memory available : 4GB

操作系统:Windows XP

Operating System : Windows XP

1.5 GB 是仅此进程使用的内存.

1.5 GB is the memory used by just this one process.

问候,

萨钦

推荐答案

这在 32 位 Windows 下完全正常.

This is perfectly normal under 32bit Windows.

除非您激活了/3gb 开关,否则您的总地址空间为 2GB.然而,这是减去映射的可执行文件和至少六个 DLL 和 NLS 文件(对于hello world"——一个真正的应用程序可能会有更多的一打或两打).

Unless you have the /3gb switch activated, you have a total address space of 2GB. However, that's minus the mapped executable and at least half a dozen DLL and NLS files (for "hello world" -- a real application would probably have more like a dozen or two dozen of them).

由于它们未处于最佳位置,您会损失大约半 GB 的地址空间.堆不会增长到"该区域,因此分配超过 1.5GB 的空间将失败.

Since they are not optimally placed, you lose about half a gigabyte of addres space. The heap will not grow "into" that region, and thus allocating more than 1.5GB will fail.

典型程序"的地址空间如下所示:

Here is what the address space of a "typical program" looks like:

请注意,将一个 DLL 放置在大约 1/3 地址空间的位置非常巧妙,有效地切断"了您可以使用的三分之一的内存.

Note how very skillfully one DLL is placed at about 1/3 of the address space, effectively "cutting off" a third of the memory that you can use.

这篇关于一旦内存使用量达到 1.5 GB,C++ 应用程序就会崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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