相关疑难解决方法(0)

32位Windows上C++应用程序可用的最大内存是多少?

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

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

如果一个C++应用程序尝试请求超过2GB内存,这会导致内存崩溃吗?

最后的问题 - 如果运行C++应用程序的机器已经内存不足而且C++应用程序要求100MB的阵列(即连续的内存),操作系统是否会通过虚拟内存来适应这种情况?

c++ windows 32-bit memory-limit

13
推荐指数
2
解决办法
2万
查看次数

分配比使用malloc存在的内存更多的内存

每次从stdin读取字母'u'时,此代码段将分配2Gb,并在读取'a'时初始化所有已分配的字符.

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#define bytes 2147483648
using namespace std;
int main()
{
    char input [1];
    vector<char *> activate;
    while(input[0] != 'q')
    {
        gets (input);
        if(input[0] == 'u')
        {
            char *m = (char*)malloc(bytes);
            if(m == NULL) cout << "cant allocate mem" << endl;
            else cout << "ok" << endl;
            activate.push_back(m);
        }
        else if(input[0] == 'a')
        {
            for(int x = 0; x < activate.size(); x++)
            {
                char *m;
                m = activate[x];
                for(unsigned x = 0; x …
Run Code Online (Sandbox Code Playgroud)

c c++ linux memory memory-management

8
推荐指数
3
解决办法
5126
查看次数

标签 统计

c++ ×2

32-bit ×1

c ×1

linux ×1

memory ×1

memory-limit ×1

memory-management ×1

windows ×1