You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 11下为何无法用C++创建超过8GiB的堆内存?

Windows 11下CLion创建大型动态数组的内存分配测试结果

测试环境:Windows 11 64位系统,32GiB内存,使用CLion编译运行C++代码。

测试代码如下:

#include <iostream>
#include <chrono>
#include <thread>

int main() {
    int len = 0;
    std::cin >> len;
    auto arg = std::make_unique<int32_t[]>(len);
    std::this_thread::sleep_for(std::chrono::seconds(100));
}

测试结果:

  • 当数组元素类型为int(4字节)时,最大可分配内存约8192MiB
  • 当数组元素类型为int16_t(2字节)时,最大可分配内存约4096MiB
  • 当数组元素类型为char(1字节)时,最大可分配内存约2048MiB

附相关截图:

  • 代码截图
  • VMMap内存分析截图
  • 任务管理器截图

内容的提问来源于stack exchange,提问作者Bob_2023

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 22:42:37