动态分配内存最大能分配多少

baidu_17369275 2014-07-08 11:24:26
在编程时,如果申请过大的动态内存,程序就会崩溃。所以想知道,怎么样根据机器的配置来计算出,可以分配的最大内存呢?
...全文
251 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
康斯坦汀 2014-07-08
  • 打赏
  • 举报
回复
32位应用程序拥有最大4 GB 的进程地址空间,但其中2G是操作系统保留的,也就是说32位应用,最大能用2G空间。 64位应用理论上是128G,Windows目前最大貌似是8G。
lx624909677 2014-07-08
  • 打赏
  • 举报
回复
32位操作系统支持“虚存”,内存用完了,可以用硬盘空间代替,也就是说堆的大小受限于计算机系统中有效的虚拟内存,堆内存理论上能分配到2G以上。
赵4老师 2014-07-08
  • 打赏
  • 举报
回复
GlobalMemoryStatus The GlobalMemoryStatus function obtains information about the computer system's current usage of both physical and virtual memory. VOID GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer // pointer to the memory status structure ); Parameters lpBuffer Pointer to a MEMORYSTATUS structure. The GlobalMemoryStatus function stores information about current memory availability into this structure. Return Values This function does not return a value. Remarks You can use the GlobalMemoryStatus function to determine how much memory your application can allocate without severely impacting other applications. The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in winbase.h. Import Library: Use kernel32.lib. See Also Memory Management Overview, Memory Management Functions, GlobalMemoryStatusVlm, MEMORYSTATUS

64,685

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧