32位Windows上的C ++应用程序可用的最大内存是多少? [英] What is the maximum memory available to a C++ application on 32-bit Windows?

查看:1046
本文介绍了32位Windows上的C ++应用程序可用的最大内存是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否有对C ++应用程序使用的最大内存的限制

Just wondering if there is a restriction on the max memory that a C++ application uses

我知道这是2GB - 是正确的吗?

I understand that this is 2GB - Is that correct?

如果C ++应用程序尝试请求更多,那么2GB内存会导致内存崩溃?

If a C++ app tries to request more then 2GB memory does this cause a memory crash?

最后一个问题 - 如果机器C ++应用程序正在运行的内存已经很低,而一个C ++应用程序要求100MB的数组(即连续内存)将通过使用虚拟内存吗?

Final question - If the machine the C++ app is running on is already low on memory and a C++ app asks for 100MB of array (ie contiguous memory) will the OS accommodate this by using virtual memory?

推荐答案

这将导致动态内存分配失败,这通常会导致应用程序崩溃,但在技术上,应用程序可以写入承受此事件。 2GB确实是单个进程的用户地址空间大小 - 应用程序可能使用多个进程(最简单的例子:Chrome)。如果应用程序要求100MB的连续内存,则该内存必须虚拟连接,即使不是物理连续的,如果没有足够的连续页面可用,那么它是一个失败的分配。

It will cause a dynamic memory allocation failure, which usually will make the resultant application crash, but technically, an application could be written to withstand this event. 2GB is indeed the user address space size for an individual process- an application may use multiple processes (easiest example: Chrome). If an application asks for 100MB of contiguous memory, that memory must be virtually contiguous even if not physically contiguous, and if there aren't enough contiguous pages available then it's a failed allocation.

总是使用虚拟内存 - 所有内存都是虚拟内存。

Virtual memory is always used- all memory is virtual.

2GB是大多数情况下的限制。通常情况下,2GB用于用户和2GB用于内核,但您可以要求Windows为用户制作3GB,为内核制作1GB(有风险),以及64位,整个4GB的32位地址空间可供用户使用。增加的地址空间只有在您编译应用程序 / LARGEADDRESSAWARE 时才可用。

2GB is the limit under most circumstances. What happens is that normally, 2GB is for the user and 2GB for the kernel, but you can ask Windows to make this 3GB for the user and 1GB for the kernel (at some risk), and on 64bit, the whole 4GB of 32bit address space is available to the user. The increased address space is only available if you compile your application as /LARGEADDRESSAWARE.

这篇关于32位Windows上的C ++应用程序可用的最大内存是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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